/* ==========================================================================
   App design examples (/learn/app-design/): page layout on our design system.
   Needs /design/tokens.css and /design/components.css first.
   This folder is the source (the laws-of-ux-examples repo is archived).

   Two zones:
   1. The page (header, text, cards, toggle, video, footer): our tokens and fonts.
   2. Inside .demo-frame: the fake apps of other companies. They keep their own
      neutral light look (the original palette and system font), in both themes,
      so the before/after demos and the videos stay the same.
   ========================================================================== */

/* Names that only the original demos use. Outside a demo they follow our tokens. */
:root {
  --border: var(--line);
  --radius: var(--radius-lg);
  --shadow: none;
  --ok: var(--success);
  --ok-soft: var(--success-soft);
  --warn: var(--warning);
  --warn-soft: var(--warning-soft);
  --accent-ink: var(--on-accent);
  --page: 60rem;
}

body { line-height: var(--leading-body); }
h1, h2, h3, h4 { line-height: var(--leading-heading); margin: 0 0 var(--space-2); }
p { margin: 0 0 var(--space-4); }

.container, .ux-top, .ux-foot {
  max-width: var(--page); margin: 0 auto; padding-inline: var(--gutter);
}

/* ---------- Header: logo + breadcrumb (same as /tools/) ---------- */
.ux-top { padding-top: calc(env(safe-area-inset-top, 0px) + var(--space-6)); }
.site-logo { display: inline-flex; align-items: center; min-height: var(--tap); padding: var(--space-2) 0; margin: 0 0 var(--space-4); }
.site-logo img { display: block; width: 170px; height: auto; }
.crumbs { margin: 0; font-size: var(--text-sm); color: var(--muted); }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.crumbs li + li::before { content: "/" / ""; margin-right: 0.4rem; color: var(--line-strong); }
.crumbs a { color: inherit; }
.crumbs a:hover { color: var(--accent); }
.crumbs [aria-current] { color: var(--ink); }

/* ---------- Footer ---------- */
.ux-foot {
  margin-top: var(--space-8);
  padding-top: var(--space-5); padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--space-7));
  border-top: 1px solid var(--line); color: var(--muted); font-size: var(--text-sm);
}
.ux-foot p { margin: 0 0 var(--space-3); max-width: var(--measure-prose); }
.ux-foot a { color: inherit; }

/* ---------- Index ---------- */
.hero { padding: var(--space-7) 0 var(--space-5); }
.hero h1 {
  font: var(--weight-semibold) clamp(2.1rem, 6.5vw, 3.2rem) / 1.08 var(--font-display);
  letter-spacing: -0.03em; margin: 0 0 var(--space-3); max-width: 20ch;
}
.hero .hero-sub {
  font: var(--weight-light) var(--text-voice) / 1.2 var(--font-display);
  letter-spacing: var(--tracking-heading); color: var(--accent); margin: 0 0 var(--space-5);
}
.hero p { max-width: var(--measure-prose); }
.hero .hero-credit { font-size: var(--text-sm); color: var(--muted); }

.progress-box {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5); margin: 0 0 var(--space-4);
}
.progress-head { margin: 0; }
#progress-count { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-bar { height: 0.55rem; background: var(--bg); border-radius: var(--radius-pill); overflow: hidden; margin-top: var(--space-3); }
.progress-bar i { display: block; height: 100%; width: 0; background: var(--gradient-bridge); border-radius: var(--radius-pill); }
@media (prefers-reduced-motion: no-preference) { .progress-bar i { transition: width var(--dur-3) var(--ease-out); } }
.progress-note { font-size: var(--text-sm); color: var(--muted); margin: var(--space-3) 0 0; }

.law-group { margin-top: var(--space-7); }
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); }
.group-head h2 {
  font: var(--weight-semibold) var(--text-h2) / var(--leading-heading) var(--font-display);
  letter-spacing: var(--tracking-heading); margin: 0;
}
.group-count { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.group-desc { color: var(--muted); max-width: var(--measure-prose); margin: var(--space-2) 0 var(--space-5); }

.law-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--space-4); }
.law-card {
  position: relative; display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-4) var(--space-5); text-decoration: none; color: var(--ink);
}
.law-card:hover { border-color: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .law-card { transition: border-color var(--dur-1); } }
.law-card .card-art {
  display: block; aspect-ratio: 4 / 3; overflow: hidden;
  margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) var(--space-2);
  border-radius: calc(var(--radius-xl) - 1px) calc(var(--radius-xl) - 1px) 0 0;
  background: #f5f6fa; border-bottom: 1px solid var(--line);
}
/* Card picture: the first frame of the page's before/after video, cropped to the app screen.
   The top of the frame has its own headline; it competed with the card title (Alexandros, phone). */
.law-card .card-art img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 100%; }
.law-card :is(h2, h3) { font: var(--weight-semibold) var(--text-h3) / 1.3 var(--font-display); margin: 0; }
.law-card p { color: var(--muted); font-size: var(--text-sm); margin: 0; }
.law-card.learned::after {
  content: "✓ Learned"; position: absolute; top: var(--space-3); right: var(--space-3);
  background: var(--success); color: var(--bg); font-size: var(--text-xs); font-weight: var(--weight-semibold);
  padding: 0.2rem 0.65rem; border-radius: var(--radius-pill);
}

/* "Start here": the same card, a little larger. */
.start-here { margin-top: var(--space-7); }
.start-here h2 {
  font: var(--weight-semibold) var(--text-h2) / var(--leading-heading) var(--font-display);
  letter-spacing: var(--tracking-heading); margin: 0;
}
.featured-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: var(--space-5); }
.law-card.featured { padding: var(--space-5) var(--space-5) var(--space-6); border-color: var(--line-strong); }
.law-card.featured .card-art { margin: calc(-1 * var(--space-5)) calc(-1 * var(--space-5)) var(--space-3); }
.law-card.featured h3 { font-size: var(--text-lg); }
.law-card.featured p { font-size: var(--text-base); }
.law-card.featured:hover { border-color: var(--accent); }

.hero-intro { font-size: var(--text-lede); line-height: 1.45; }

/* Bottom of the index: who made this, two short lines for other readers, then the progress box. */
/* Section titles sit above their box (design system rule). */
.maker-area { margin-top: var(--space-8); }
.maker { padding: var(--space-6); border-radius: var(--radius-xl); background: var(--accent-soft); }
.maker-area > h2, .progress-area > h2, .also-for > h2 { font: var(--weight-semibold) var(--text-h2) / var(--leading-heading) var(--font-display); letter-spacing: var(--tracking-heading); margin: 0 0 var(--space-3); }
.maker p { max-width: var(--measure-prose); }
.maker > p:first-child { margin-top: 0; }
.maker .noscript-email { margin: var(--space-3) 0 0; }
.also-for { margin: var(--space-6) 0; color: var(--muted); }
.also-for p { max-width: var(--measure-prose); margin: 0 0 var(--space-2); }
.also-for strong, .also-for > h2 { color: var(--ink); }
.progress-area { margin-top: var(--space-6); }
.progress-area.at-top { margin: 0 0 var(--space-4); }
.progress-box { margin: 0; }

/* Texts that are not final yet. scripts/check-ux-license.py fails while one is on a page. */
.placeholder { background: var(--warning-soft); color: var(--warning); border-radius: var(--radius-sm); padding: 0 0.3em; }

.law-card .card-law, .law-intro .law-eyebrow {
  font: var(--weight-regular) var(--text-xs) / 1.3 var(--font-mono);
  letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--accent);
}
.law-intro .law-eyebrow { margin: 0 0 var(--space-3); font-size: var(--text-sm); }

.audience { padding-top: var(--space-7); }
.audience h2 {
  font: var(--weight-semibold) var(--text-h2) / var(--leading-heading) var(--font-display);
  letter-spacing: var(--tracking-heading); margin: 0 0 var(--space-5);
}
.aud-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); }
.aud-card { background: var(--surface); border-radius: var(--radius-xl); padding: var(--space-5); }
.aud-card h3 { font: var(--weight-semibold) var(--text-h3) / 1.3 var(--font-display); margin: 0 0 var(--space-2); }
.aud-card p { color: var(--muted); font-size: var(--text-sm); margin: 0; }

/* ---------- Law page ---------- */
.law-intro { padding: var(--space-7) 0 var(--space-4); }
.law-intro h1 {
  font: var(--weight-semibold) clamp(2rem, 5.5vw, 2.9rem) / 1.08 var(--font-display);
  letter-spacing: -0.03em; margin: 0 0 var(--space-4); max-width: 24ch;
}
/* The guideline: what to do, in Alexandros' words. */
.law-intro .guideline {
  font: var(--weight-light) var(--text-lede) / 1.4 var(--font-display); color: var(--ink);
  max-width: var(--measure-prose); border-left: 3px solid var(--accent); padding-left: var(--space-4); margin: var(--space-4) 0 var(--space-2);
}
/* Where the guideline comes from: the law name and a link to its lawsofux.com page. */
.law-intro .law-line { font-size: var(--text-sm); color: var(--muted); max-width: var(--measure-prose); margin: 0 0 var(--space-5); padding-left: calc(var(--space-4) + 3px); }
.law-intro .plain-words { max-width: var(--measure-prose); background: var(--accent-soft); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); }
.law-intro .takeaway { max-width: var(--measure-prose); }
@media (max-width: 640px) { .law-intro { padding-top: var(--space-6); } }

/* Video: a 15-second before/after summary above the interactive demo. */
.law-film { margin: var(--space-2) auto var(--space-6); max-width: 34rem; }
.law-film .law-film-box {
  position: relative; aspect-ratio: 1 / 1; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface);
}
.law-film video { display: block; width: 100%; height: 100%; object-fit: cover; }
.law-film .law-film-toggle {
  position: absolute; right: var(--space-3); bottom: var(--space-3);
  min-height: 36px; padding: 0 0.9rem; border: 0; border-radius: var(--radius-pill);
  background: rgb(17 15 23 / .8); color: #fff; font-size: var(--text-sm); font-weight: var(--weight-semibold); cursor: pointer;
}
.law-film .law-film-toggle:hover { background: rgb(17 15 23 / .94); }
.law-film figcaption { font-size: var(--text-sm); color: var(--muted); text-align: center; margin-top: var(--space-3); }

/* "Try it yourself": the title of the interactive part. */
.try-title { font: var(--weight-semibold) var(--text-h3) / 1.3 var(--font-display); margin: var(--space-6) 0 var(--space-2); }
.try-lead { color: var(--muted); margin: 0; }
.try-lead + .toggle { margin-top: var(--space-4); }

/* Before / After switch: stays at the top of the screen while you scroll the demo. */
.toggle {
  position: sticky; top: var(--space-3); z-index: var(--z-sticky);
  display: flex; gap: var(--space-1); width: fit-content; margin: var(--space-5) 0 var(--space-4);
  padding: var(--space-1); border: 1px solid var(--line); border-radius: var(--radius-pill);
  background: var(--bg); box-shadow: var(--shadow-pop);
}
.toggle button {
  min-height: 40px; padding: 0 1.2rem; border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--muted); font-weight: var(--weight-semibold); cursor: pointer;
}
.toggle button:hover { color: var(--ink); }
.toggle button.active[data-panel="before"] { background: var(--danger); color: var(--bg); }
.toggle button.active[data-panel="after"] { background: var(--success); color: var(--bg); }

.panel { margin-bottom: var(--space-4); }
.callout { border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); border-left: 4px solid; }
.callout.bad { background: var(--danger-soft); border-color: var(--danger); }
.callout.good { background: var(--success-soft); border-color: var(--success); }
.callout strong { display: block; margin-bottom: var(--space-1); font-family: var(--font-display); }
.callout.bad strong { color: var(--danger); }
.callout.good strong { color: var(--success); }

/* Closing line after the demo: what the change means for the business (Sales, Support calls, Building trust). No research notes (Alexandros: keep it simple). */
.impact-area { margin: var(--space-6) 0 0; }
.impact { padding: var(--space-5); border-radius: var(--radius-xl); background: var(--accent-soft); }
/* Section titles outside their box (design system rule): "Apply this rule…", "Your progress", "More examples". */
.learn-area, .pager-area, .cta-area { margin-top: var(--space-6); }
/* Call to action on law pages: .card (the purple .card.soft is the takeaway above). */
.cta p { margin: 0 0 var(--space-4); max-width: var(--measure-prose); }
.cta .noscript-email { margin: var(--space-3) 0 0; }
.section-title, .impact-title { font: var(--weight-semibold) var(--text-h3) / 1.3 var(--font-display); margin: 0 0 var(--space-3); }
.impact-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-3); }
.impact-tags .pill { background: var(--bg); }
.impact-line { font: var(--weight-semibold) var(--text-lg) / 1.35 var(--font-display); max-width: var(--measure-prose); margin: 0; }


.learn-check {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-4);
  border: 1px solid var(--line); border-radius: var(--radius-xl); padding: var(--space-4) var(--space-5); margin: 0;
}
.learn-btn {
  min-height: var(--tap); padding: 0 1.25rem; border: 2px solid var(--success); border-radius: var(--radius-pill);
  background: transparent; color: var(--success); font-weight: var(--weight-semibold); cursor: pointer; white-space: nowrap;
}
.learn-btn:hover { background: var(--success-soft); }
.learn-btn.is-learned { background: var(--success); color: var(--bg); }
/* Both labels in one grid cell: the button keeps the width of the longer one. */
.learn-btn { position: relative; display: inline-grid; transition: background-color var(--dur-1), color var(--dur-1); }
.learn-btn .lb { grid-area: 1 / 1; display: inline-flex; align-items: center; justify-content: center; gap: .35em; }
.learn-btn:not(.is-learned) .lb-done, .learn-btn.is-learned .lb-mark { visibility: hidden; }
.learn-btn svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.learn-check { transition: border-color 400ms; }
.learn-check.all-done { border-color: var(--success); }
.burst { position: absolute; inset: 0; pointer-events: none; }
.burst i { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .learn-btn.pop { animation: learn-pop 420ms cubic-bezier(.34, 1.56, .64, 1); }
  .learn-btn.pop .lb-done path { stroke-dasharray: 24; animation: check-draw 260ms ease-out 120ms both; }
  .burst i { animation: burst-dot 600ms ease-out 60ms; }
  .burst.big i { animation-duration: 900ms; }
}
@keyframes learn-pop { 25% { transform: scale(.94); } 60% { transform: scale(1.06); } to { transform: none; } }
@keyframes check-draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
@keyframes burst-dot {
  from { transform: translate(var(--sx), var(--sy)) scale(1); opacity: 0; }
  10%, 60% { opacity: 1; }
  to { transform: translate(var(--x), var(--y)) scale(.4); opacity: 0; }
}
.learn-check p { margin: 0; font-size: var(--text-sm); color: var(--muted); flex: 1 1 16rem; }

.law-pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.pager-link {
  display: flex; flex-direction: column; gap: var(--space-1);
  border: 1px solid var(--line); border-radius: var(--radius-xl); padding: var(--space-4) var(--space-5);
  text-decoration: none; color: var(--ink);
}
.pager-link:hover { border-color: var(--accent); }
.pager-link.next { text-align: right; }
.pager-link .pager-dir { font-size: var(--text-sm); color: var(--muted); }
.pager-link .pager-name { font-family: var(--font-display); font-weight: var(--weight-semibold); }
@media (max-width: 480px) {
  .law-pager { grid-template-columns: 1fr; }
  .pager-link.next { text-align: left; }
}

/* ==========================================================================
   2. Inside a demo: the original neutral palette, light in both themes.
   ========================================================================== */
.demo-frame {
  color-scheme: light;
  --bg: #f5f6fa; --surface: #ffffff; --ink: #1c2130; --muted: #5b6478;
  --accent: #4f46e5; --accent-soft: #eef0fe; --accent-ink: #ffffff;
  --danger: #b91c1c; --danger-soft: #fdeaea; --ok: #116d33; --ok-soft: #e8f6ec;
  --warn: #9a4a06; --warn-soft: #fdf3e3; --border: #e3e6ef; --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .07);
  --focus-color: #4f46e5;

  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  font: 400 1rem / 1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
.demo-frame :is(h1, h2, h3, h4) { font-family: inherit; line-height: 1.2; margin: 0 0 .5rem; }
.demo-frame p { margin: 0 0 1rem; }
.demo-frame a { color: var(--accent); }
.demo-frame .frame-bar {
  display: flex; align-items: center; gap: .5rem;
  background: #eceef4; border-bottom: 1px solid var(--border); padding: .55rem .9rem;
}
.demo-frame .frame-bar .dots { display: flex; gap: .35rem; }
.demo-frame .frame-bar .dots i { width: .65rem; height: .65rem; border-radius: 50%; background: #cdd2e0; }
.demo-frame .frame-bar .url {
  flex: 1; max-width: 22rem; background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  font-size: .75rem; color: var(--muted); padding: .15rem .7rem;
}
.demo-frame .frame-body { padding: 1.5rem; }
@media (max-width: 600px) { .demo-frame .frame-body { padding: 1rem; } }

/* Generic fake-product UI. These names also exist in /design/components.css,
   so each rule sets every property that our component sets. */
.demo-frame .btn {
  display: inline-block; gap: 0; min-height: 0; padding: .5rem 1rem;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; line-height: normal; text-decoration: none; white-space: normal;
  cursor: pointer; transition: none;
}
.demo-frame .btn:hover { border-color: var(--accent); background: var(--surface); }
.demo-frame .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.demo-frame .btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.demo-frame .btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.demo-frame .field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.demo-frame .field label { font-size: .85rem; font-weight: 600; }
.demo-frame .field :is(input, select, textarea) {
  font: inherit; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem;
  background: var(--surface); color: var(--ink);
}
.demo-frame .field :is(input, select, textarea):focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.demo-frame .field .hint { font-size: .78rem; color: var(--muted); }
.demo-frame .error-text { color: var(--danger); font-size: .82rem; }
.demo-frame .ok-text { color: var(--ok); font-size: .82rem; }
.demo-frame .skeleton {
  border-radius: 6px; background: linear-gradient(90deg, #edeff5 25%, #f7f8fc 50%, #edeff5 75%);
  background-size: 200% 100%; animation: shimmer 1.1s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .demo-frame .skeleton { animation: none; } }
