/* ============================================================
   ADR Downloader — UI v3 "paper & ink"
   Design language extracted from tryclico.com:
     neo-brutalist outline + zero-blur offset shadow,
     cream paper card on lavender field, graph-paper substrate,
     Instrument Serif display / Instrument Sans UI / JetBrains Mono micro.
   Class + ID names unchanged → static/app.js untouched.
   ============================================================ */

:root {
  /* --- palette (verbatim from clico tokens) --- */
  --bg-page: #c8bff5;
  --bg-card: #f6f3ec;
  --bg-white: #ffffff;
  --ink: #0a0a0a;
  --ink-secondary: #4a4a4a;
  --ink-tertiary: #6e6e6e;
  --border: #0a0a0a;
  --border-light: rgba(10, 10, 10, 0.12);
  --highlight: #c1f04c;
  --brand-blue: #5b5bd6;
  --brand-orange: #f26b3a;

  /* per-platform accent, overridden inline by the template */
  --accent1: #5b5bd6;
  --accent2: #f26b3a;

  /* --- structure --- */
  --shadow-hard: 2px 2px 0 var(--border);
  --shadow-btn: 3px 3px 0 var(--border);
  --shadow-btn-hover: 5px 5px 0 var(--border);
  --shadow-card: 4px 4px 0 var(--border);
  --radius: 6px;
  --radius-lg: 10px;
  --bounce: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  --grid-line: rgba(120, 100, 80, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  background: var(--bg-page);
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  padding: 22px 16px 38px;
}
@media (min-width: 900px) { body { padding: 36px 40px 56px; } }

a { color: inherit; text-decoration: none; }

/* ============ the cream paper sheet on the lavender field ============ */
.container {
  position: relative;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 22px 34px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--border);
  overflow: hidden;
  min-height: auto;
  display: flex;
  flex-direction: column;
  /* graph-paper substrate */
  background-image:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 0),
    linear-gradient(var(--grid-line) 1px, transparent 0);
  background-size: 24px 24px, 24px 24px;
}
@media (min-width: 1024px) {
  .container { padding: 30px 46px 42px; }
}

/* soft accent bloom at the top of the sheet, tinted per platform */
.container::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 340px;
  pointer-events: none;
  background:
    radial-gradient(60% 100% at 50% 0%,
      color-mix(in srgb, var(--accent1) 16%, transparent) 0%, transparent 72%);
}
.container > * { position: relative; }

/* ---------------- entrance ---------------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.brand, .card, .platform-grid > *, .tips, .footer-note, .stats {
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.brand             { animation-delay: 0.02s; }
.card              { animation-delay: 0.08s; }
.platform-grid > * { animation-delay: calc(0.06s + var(--i, 0) * 0.04s); }
.stats             { animation-delay: 0.14s; }
.tips              { animation-delay: 0.16s; }
.footer-note       { animation-delay: 0.2s; }

/* ========================= BRAND / HERO ========================= */
.brand {
  text-align: center;
  padding: 20px 0 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border-light);
}

/* wordmark row: lime tile + CLICO-style logotype */
.brand .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--bg-white);
  box-shadow: var(--shadow-hard);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
}
.brand .eyebrow .live {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--highlight);
  border: 1.5px solid var(--border);
  animation: blink 2.6s steps(1, end) infinite;
}
@keyframes blink { 0%, 62% { opacity: 1; } 63%, 100% { opacity: 0.28; } }

/* Instrument Serif display headline, italic accent word */
.brand h1 {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.6rem, 9vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.brand h1 em {
  font-style: italic;
  color: var(--brand-blue);
  position: relative;
}
.brand h1 .lime {
  font-style: italic;
  position: relative;
  z-index: 1;
}
.brand h1 .lime::after {   /* highlighter swipe */
  content: '';
  position: absolute;
  left: -0.07em; right: -0.07em;
  top: 0.15em;
  bottom: 0.17em;
  background: var(--highlight);
  z-index: -1;
  border-radius: 2px;
  transform: skewX(-7deg);
}

.brand .subtitle {
  max-width: 44ch;
  margin: 16px auto 0;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink-secondary);
}

/* back link, styled as an outlined chip */
.brand .back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  margin-bottom: 20px;
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
  box-shadow: var(--shadow-hard);
  font-size: 0.83rem;
  font-weight: 600;
  transition: var(--bounce);
}
.brand .back:hover {
  background: var(--highlight);
  box-shadow: 4px 4px 0 var(--border);
  transform: translate(-2px, -2px);
}
.brand .back:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }

/* ========================== CARDS ========================== */
.card {
  background: var(--bg-white);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px 24px 30px;
  margin-bottom: 22px;
}
@media (min-width: 720px) { .card { padding: 30px 30px 36px; } }

label {
  display: block;
  margin-bottom: 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-secondary);
}

/* ---------------- input ---------------- */
input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 2px solid var(--border) !important;
  border-radius: var(--radius);
  color: var(--ink);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  outline: none;
  transition: var(--bounce);
}
input[type="text"]:focus {
  background: var(--bg-white);
  box-shadow: var(--shadow-btn);
  transform: translate(-1px, -1px);
}
input[type="text"]::placeholder { color: var(--ink-tertiary); }

/* ---------------- primary button (lime, hard shadow) ---------------- */
button.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 18px;
  padding: 14px 28px;
  background: var(--highlight);
  color: var(--ink);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-btn);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--bounce);
}
button.primary:hover {
  box-shadow: var(--shadow-btn-hover);
  transform: translate(-2px, -2px);
}
button.primary:active { box-shadow: 1px 1px 0 var(--border); transform: translate(1px, 1px); }
button.primary:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 3px; }
button.primary:disabled {
  background: var(--bg-card);
  color: var(--ink-tertiary);
  box-shadow: 1px 1px 0 var(--border-light);
  border-color: var(--border-light);
  transform: none;
  cursor: not-allowed;
}

/* ==================== PLATFORM GRID (home) ==================== */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 720px) {
  .platform-grid { grid-template-columns: repeat(4, 1fr); gap: 18px 20px; }
}

.platform-card {
  --pc-color: var(--brand-blue);
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 16px 16px;
  min-height: 152px;
  background: var(--bg-white);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard);
  cursor: pointer;
  overflow: hidden;
  transition: var(--bounce);
}
/* clipped color wedge in the corner — clico's feat-grid device */
.platform-card::after {
  content: '';
  position: absolute;
  inset: 0 0 0 auto;
  width: 34%;
  z-index: 0;
  pointer-events: none;
  clip-path: polygon(48% 0, 100% 0, 100% 100%, 88% 100%);
  background: color-mix(in srgb, var(--pc-color) 14%, transparent);
  background-image:
    linear-gradient(90deg, color-mix(in srgb, var(--pc-color) 26%, transparent) 1px, transparent 0),
    linear-gradient(color-mix(in srgb, var(--pc-color) 26%, transparent) 1px, transparent 0);
  background-size: 12px 12px;
  transition: var(--bounce);
}
.platform-card:hover,
.platform-card:focus-visible {
  outline: none;
  box-shadow: 5px 5px 0 var(--border);
  transform: translate(-3px, -3px);
}
.platform-card:hover::after { width: 42%; }
.platform-card > * { position: relative; z-index: 1; }
.platform-card:active { box-shadow: 1px 1px 0 var(--border); transform: translate(1px, 1px); }

.platform-card .icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--pc-color);
  box-shadow: var(--shadow-hard);
  color: var(--bg-white);
  transition: var(--bounce);
}
.platform-card .icon svg { width: 22px; height: 22px; display: block; fill: currentColor; }
.platform-card .icon svg * { fill: currentColor; }
.platform-card:hover .icon { transform: rotate(-6deg) scale(1.06); }

.platform-card .name {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.32rem;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.platform-card .desc {
  margin-top: auto;
  padding-top: 9px;
  width: 100%;
  border-top: 1px solid var(--border-light);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.6px;
  line-height: 1.45;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

/* wide catch-all card */
.platform-card.all {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  min-height: auto;
  padding: 18px 26px 18px 22px;
  gap: 16px;
  background: var(--highlight);
}
.platform-card.all .text { min-width: 0; }
.platform-card.all::after { width: 22%; inset: 0 0 0 auto; clip-path: polygon(44% 0, 86% 0, 72% 100%, 30% 100%); }
.platform-card.all:hover::after { width: 30%; }
.platform-card.all .icon { flex-shrink: 0; background: var(--ink); }
.platform-card.all .name { font-size: 1.34rem; line-height: 1.15; }
.platform-card.all .desc {
  margin-top: 4px;
  padding-top: 0;
  border-top: none;
  text-transform: none;
  letter-spacing: 0;
  font-size: 10.5px;
}
.platform-card.all .arrow {
  margin-left: auto;
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 2px solid var(--border);
  border-radius: 99px;
  background: var(--bg-white);
  font-size: 1rem;
  transition: var(--bounce);
}
.platform-card.all:hover .arrow { transform: translateX(4px); background: var(--bg-card); }

/* --------- stats strip --------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 18px 0 0;
}
@media (min-width: 720px) { .stats { gap: 18px 20px; margin-top: 20px; } }
.stats .stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 12px;
  background: var(--bg-white);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-btn);
  text-align: center;
}
.stats .stat b {
  display: block;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--brand-blue);
}
.stats .stat span {
  display: block;
  margin-top: 5px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

/* ===================== PLATFORM BADGE (feat-tag) ===================== */
.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 20px;
  padding: 5px 14px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  box-shadow: var(--shadow-hard);
  background: color-mix(in srgb, var(--accent1) 20%, var(--bg-white));
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink);
}
.platform-badge .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--accent1);
}

/* ========================= PREVIEW ========================= */
#preview { display: none; }

.preview-card {
  display: flex;
  gap: 16px;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}
.preview-card img {
  width: 136px;
  height: 78px;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  /* photos read as B/W paste-ups, clico-style */
  filter: grayscale(1) contrast(1.08);
  transition: var(--bounce);
}
.preview-card img:hover { filter: none; }
.preview-info { min-width: 0; }
.preview-info h3 {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.24rem;
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: -0.02em;
  margin-bottom: 5px;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.preview-info p {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}

.dl-section { margin-top: 22px; }
.dl-section h4 {
  margin-bottom: 14px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-secondary);
}
.dl-links { display: flex; flex-direction: column; gap: 10px; }

/* ---------------- download buttons ---------------- */
.dl-link-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 13px 17px;
  background: var(--highlight);
  color: var(--ink);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-btn);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: var(--bounce);
}
.dl-link-btn:hover {
  box-shadow: var(--shadow-btn-hover);
  transform: translate(-2px, -2px);
}
.dl-link-btn:active { box-shadow: 1px 1px 0 var(--border); transform: translate(1px, 1px); }
.dl-link-btn:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 3px; }

.dl-link-btn .label { display: flex; align-items: center; gap: 9px; min-width: 0; }
.dl-link-btn .meta {
  flex-shrink: 0;
  max-width: 44%;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.6px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dl-link-btn.loading { opacity: 0.6; cursor: wait; transform: none; }

.dl-link-btn.dl-secondary { background: var(--bg-white); }
.dl-link-btn.dl-secondary:hover { background: var(--bg-card); }

.dl-audio-btn { background: var(--brand-orange); color: var(--bg-white); }
.dl-audio-btn .meta { color: rgba(255, 255, 255, 0.82); }

/* =========================== TIPS =========================== */
.tips {
  margin-top: 4px;
  padding: 16px 18px;
  background: var(--bg-white);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hard);
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--ink-secondary);
}
.tips strong {
  display: inline-block;
  margin-bottom: 3px;
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.06rem;
  font-weight: 400;
  font-style: italic;
  color: var(--ink);
}

.footer-note {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.4px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.7;
  color: var(--ink-tertiary);
}

/* ========================= SPINNERS ========================= */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====================== DOWNLOAD OVERLAY ====================== */
.dl-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 26px;
  background: color-mix(in srgb, var(--bg-page) 92%, var(--ink));
  animation: fade 0.2s ease both;
}
.dl-overlay.active { display: flex; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* the overlay body is itself a paper card */
.dl-overlay .big-spinner {
  width: 46px; height: 46px;
  border: 3px solid var(--border);
  border-top-color: var(--highlight);
  border-right-color: var(--highlight);
  border-radius: 50%;
  animation: spin 0.9s cubic-bezier(0.6, 0.2, 0.4, 0.8) infinite;
}
.dl-overlay .dl-status {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--ink);
}
.dl-overlay .dl-sub {
  max-width: 36ch;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.03em;
  text-align: center;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}
.dl-overlay .dl-progress-bar {
  width: min(300px, 80vw);
  height: 14px;
  background: var(--bg-white);
  border: 2px solid var(--border);
  border-radius: 99px;
  box-shadow: var(--shadow-hard);
  overflow: hidden;
}
.dl-overlay .dl-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--highlight);
  border-right: 2px solid var(--border);
  transition: width 0.3s ease;
}
.dl-overlay .dl-progress-fill.indeterminate {
  width: 100% !important;
  border-right: none;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--highlight) 0 10px,
    var(--bg-white) 10px 20px
  );
  background-size: 28px 28px;
  animation: marching 0.7s linear infinite;
}
@keyframes marching {
  from { background-position: 0 0; }
  to   { background-position: 28px 0; }
}
.dl-overlay .dl-cancel {
  width: auto;
  margin-top: 4px;
  padding: 10px 24px;
  background: var(--bg-white);
  color: var(--ink);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-btn);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--bounce);
}
.dl-overlay .dl-cancel:hover {
  box-shadow: var(--shadow-btn-hover);
  transform: translate(-2px, -2px);
}

/* ========================= ERROR BOX ========================= */
.error-box {
  display: none;
  margin-top: 14px;
  padding: 12px 15px;
  background: color-mix(in srgb, var(--brand-orange) 16%, var(--bg-white));
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--ink);
}
.error-box.show {
  display: block;
  animation: shake 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-5px); }
  75%      { transform: translateX(5px); }
}

/* ===================== A11Y / FALLBACKS ===================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .platform-card::after { background: rgba(91, 91, 214, 0.12); }
  .platform-badge       { background: #ffffff; }
  .dl-overlay           { background: #c8bff5; }
  .error-box            { background: #fde4d9; }
}

@media (max-width: 420px) {
  .container { padding: 22px 16px 30px; }
  .card { padding: 20px 18px; }
  .preview-card { flex-direction: column; align-items: flex-start; }
  .preview-card img { width: 100%; height: 176px; }
  .dl-link-btn { font-size: 13.5px; padding: 12px 14px; }
  .dl-link-btn .meta { max-width: 38%; }
  .stats .stat b { font-size: 1.4rem; }
}

::selection { background: var(--highlight); color: var(--ink); }

::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--bg-page); }
::-webkit-scrollbar-thumb {
  background: var(--ink);
  border: 3px solid var(--bg-page);
  border-radius: 99px;
}
