/* ==============================================
   ThumbSizer — Styles
   ============================================== */

/* --- Custom Properties --- */
:root,
[data-theme="dark"] {
  --bg-base: #121212;
  --bg-raised: #1a1a1a;
  --bg-card: #1f1f1f;
  --bg-card-hover: #242424;
  --bg-input: #161616;
  --bg-input-focus: #1c1c1c;
  --text-primary: #e8e8e8;
  --text-secondary: #8a8a8a;
  --text-muted: #585858;
  --text-placeholder: #454545;
  --accent: #e53e3e;
  --accent-hover: #f56565;
  --accent-muted: rgba(229, 62, 62, 0.12);
  --accent-glow: rgba(229, 62, 62, 0.06);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(229, 62, 62, 0.4);
  --danger: #ff5c6a;
  --danger-hover: #ff6e7a;
  --danger-muted: rgba(255, 92, 106, 0.1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  --yt-bg: #0f0f0f;
  --yt-card: #1a1a1a;
  --yt-text: #f1f1f1;
  --yt-secondary: #aaaaaa;
  --yt-chip: #272727;
  --yt-chip-text: #f1f1f1;
}

[data-theme="light"] {
  --bg-base: #f4f4f5;
  --bg-raised: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa;
  --bg-input: #efefef;
  --bg-input-focus: #e4e4e4;
  --text-primary: #18181b;
  --text-secondary: #6b6b6b;
  --text-muted: #a1a1a1;
  --text-placeholder: #c4c4c4;
  --accent: #e53e3e;
  --accent-hover: #c53030;
  --accent-muted: rgba(229, 62, 62, 0.08);
  --accent-glow: rgba(229, 62, 62, 0.04);
  --border: rgba(0, 0, 0, 0.07);
  --border-hover: rgba(0, 0, 0, 0.13);
  --border-focus: rgba(229, 62, 62, 0.4);
  --danger: #e53e3e;
  --danger-hover: #c53030;
  --danger-muted: rgba(229, 62, 62, 0.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --yt-bg: #ffffff;
  --yt-card: #ffffff;
  --yt-text: #0f0f0f;
  --yt-secondary: #606060;
  --yt-chip: #f2f2f2;
  --yt-chip-text: #0f0f0f;
}

/* Radii & Transitions */
:root {
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --ease-fast: 120ms ease;
  --ease-normal: 200ms ease;
  --ease-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--ease-normal), color var(--ease-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; border: none; background: none; color: inherit; }
a { color: inherit; text-decoration: none; }

/* --- Accent Bar --- */
.accent-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, #ff8a65 50%, var(--accent) 100%);
  background-size: 200% 100%;
  animation: shimmer 4s ease infinite;
  z-index: 1000;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 0%; }
}

/* --- Header --- */
.header {
  position: sticky;
  top: 3px;
  z-index: 100;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--ease-normal), border-color var(--ease-normal);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  transition: color var(--ease-fast);
}

.logo-icon { color: var(--accent); }

.logo:hover { color: var(--accent); }

.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--ease-fast);
}

.theme-toggle:hover {
  background: var(--accent-muted);
  color: var(--accent);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* --- Main Layout --- */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* --- Hero / Upload --- */
.hero {
  padding: 60px 0 40px;
  text-align: center;
}

.hero-content { margin-bottom: 36px; }

.hero-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 12px;
}

.hero-title .accent { color: var(--accent); }

.hero-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.6;
}

.upload-area {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 56px 32px;
  cursor: pointer;
  transition: all var(--ease-normal);
  background: var(--bg-card);
  outline: none;
}

.upload-area:hover,
.upload-area:focus-visible {
  border-color: var(--accent);
  background: var(--accent-glow);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.upload-area.dragging {
  border-color: var(--accent);
  background: var(--accent-muted);
  box-shadow: 0 0 0 4px var(--accent-muted), 0 0 40px var(--accent-glow);
  transform: scale(1.01);
}

.upload-content { pointer-events: none; }

.upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-muted);
  color: var(--accent);
  margin-bottom: 20px;
  transition: all var(--ease-normal);
}

.upload-area:hover .upload-icon {
  background: var(--accent);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(229, 62, 62, 0.3);
}

.upload-text {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.upload-subtext {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.upload-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-input);
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
}

/* --- Results Section --- */
.results {
  display: none;
  animation: fadeUp 500ms var(--ease-slow) both;
}

.results.visible { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Controls Bar --- */
.controls-bar {
  position: sticky;
  top: 59px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  margin-bottom: 32px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--ease-normal), border-color var(--ease-normal);
}

.btn-new {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  transition: all var(--ease-fast);
}

.btn-new:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 12px rgba(229, 62, 62, 0.3);
}

.controls-right { display: flex; align-items: center; gap: 8px; }

.control-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--ease-fast);
}

.control-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--accent-glow);
}

.control-btn.active {
  color: var(--accent);
  border-color: var(--border-focus);
  background: var(--accent-muted);
}

/* --- Section Label --- */
.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-label-row .section-label { margin-bottom: 0; }

.size-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-muted);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
}

/* --- Details Section --- */
.details-section { margin-bottom: 40px; }

.details-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: background var(--ease-normal), border-color var(--ease-normal);
}

.palette-area { margin-bottom: 24px; }

.palette-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.palette-bar {
  display: flex;
  height: 36px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.palette-bar-segment {
  transition: flex var(--ease-normal);
  position: relative;
}

.palette-bar-segment:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.palette-bar-segment:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.palette-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--ease-fast);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.swatch:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.swatch-color {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}

.swatch-pct {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 2px;
}

.details-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 24px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.detail-item {
  padding: 14px 16px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  transition: all var(--ease-fast);
}

.detail-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-input-focus);
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.detail-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-value .tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-pass {
  background: rgba(72, 187, 120, 0.15);
  color: #48bb78;
}

.tag-warn {
  background: rgba(236, 201, 75, 0.15);
  color: #ecc94b;
}

.tag-fail {
  background: var(--danger-muted);
  color: var(--danger);
}

.detail-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* --- Original Preview --- */
.original-section { margin-bottom: 48px; }

.original-wrapper {
  display: flex;
  justify-content: center;
}

.original-preview {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: #000;
}

.original-preview img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* --- Grid Overlay --- */
.grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ease-normal);
}

.grid-overlay.active { opacity: 1; }

.grid-overlay img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

/* --- Preview Sections --- */
.preview-section { margin-bottom: 48px; }

.previews-web,
.previews-mobile {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Sized thumbnail container — locks each preview to its real pixel width */
.yt-sized-thumb {
  max-width: 100%;
}

/* --- YouTube Mockup Cards --- */
.yt-context-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--ease-normal);
}

.yt-context-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.yt-context-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.yt-context-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.yt-context-size {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.yt-mockup {
  padding: 20px;
  background: var(--yt-bg);
  transition: background var(--ease-normal);
}

/* Shared thumb wrapper inside sized containers */
.yt-sized-thumb .yt-thumb-wrapper {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #000;
  width: 100%;
}

.yt-sized-thumb .yt-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Home Large */
.yt-home-large .yt-thumb-wrapper {
  border-radius: 12px;
}

.yt-duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  line-height: 1.4;
}

.yt-meta {
  display: flex;
  gap: 12px;
  padding-top: 12px;
}

.yt-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--yt-chip);
  flex-shrink: 0;
}

.yt-info { min-width: 0; flex: 1; }

.yt-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--yt-text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.yt-channel {
  font-size: 12px;
  color: var(--yt-secondary);
  line-height: 1.4;
}

.yt-stats {
  font-size: 12px;
  color: var(--yt-secondary);
  line-height: 1.4;
}

/* Home Small */
.yt-home-small .yt-meta { gap: 10px; padding-top: 10px; }
.yt-home-small .yt-avatar { width: 32px; height: 32px; }
.yt-home-small .yt-title { font-size: 13px; }
.yt-home-small .yt-channel, .yt-home-small .yt-stats { font-size: 11px; }

/* Search Result */
.yt-search .yt-mockup-inner {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.yt-search .yt-thumb-wrapper { border-radius: 10px; }
.yt-search .yt-search-info { flex: 1; min-width: 0; padding-top: 4px; }
.yt-search .yt-title { font-size: 16px; margin-bottom: 8px; }
.yt-search .yt-stats { margin-bottom: 10px; }

.yt-search .yt-description {
  font-size: 12px;
  color: var(--yt-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.yt-search .yt-channel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.yt-search .yt-channel-row .yt-avatar { width: 24px; height: 24px; }

/* Sidebar / Suggested */
.yt-sidebar .yt-mockup-inner {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.yt-sidebar .yt-info { padding-top: 0; }
.yt-sidebar .yt-title { font-size: 13px; line-height: 1.3; margin-bottom: 4px; }
.yt-sidebar .yt-channel, .yt-sidebar .yt-stats { font-size: 11px; }

/* Channel Page */
.yt-channel-page .yt-title { font-size: 13px; padding-top: 10px; margin-bottom: 4px; }
.yt-channel-page .yt-stats { font-size: 11px; }

/* Mobile Feed */
.yt-mobile-feed .yt-thumb-wrapper { border-radius: 0; }
.yt-mobile-feed .yt-meta { padding: 12px 0 0; gap: 12px; }

/* Notification */
.yt-notification .yt-mockup-inner {
  display: flex;
  gap: 12px;
  align-items: center;
}

.yt-notification .yt-avatar { width: 40px; height: 40px; flex-shrink: 0; }

.yt-notification .yt-notif-text {
  flex: 1;
  min-width: 0;
}

.yt-notification .yt-notif-text p {
  font-size: 13px;
  color: var(--yt-text);
  line-height: 1.4;
}

.yt-notification .yt-notif-text .yt-stats {
  font-size: 11px;
  margin-top: 2px;
}

.yt-notification .yt-thumb-wrapper { border-radius: 6px; }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 10px 24px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 300ms cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .main { padding: 0 16px 60px; }
  .hero { padding: 40px 0 24px; }
  .hero-title { font-size: 26px; }
  .hero-subtitle { font-size: 14px; }
  .upload-area { padding: 40px 20px; }
  .controls-bar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .details-card { padding: 20px; }
  .details-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .palette-swatches { gap: 6px; }
  .swatch { padding: 5px 8px 5px 5px; font-size: 11px; }
  .swatch-color { width: 18px; height: 18px; }
  .yt-search .yt-mockup-inner { flex-direction: column; }
  .yt-search .yt-mockup-inner .yt-sized-thumb { width: 100% !important; }
}

@media (max-width: 480px) {
  .header-inner { padding: 0 16px; }
  .hero { padding: 28px 0 20px; }
  .hero-title { font-size: 22px; }
  .control-btn span { display: none; }
  .details-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Utility --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
