/* ==========================================================================
   Foundryline demo system
   --------------------------------------------------------------------------
   WHAT WAS WRONG BEFORE

   The five demo templates were 150-line pages sharing one 200-line stylesheet
   with twenty-five classes. They all had the same rhythm, the same spacing,
   the same grey cards, and one hero each. Anybody could see in three seconds
   that they were knock-ups, which is fatal on a page whose entire argument is
   "look how carefully we build".

   WHAT THIS FILE IS

   Real components, so each demo is assembled from proper parts rather than
   hand-rolled divs. Every demo supplies its own theme block — six colour
   tokens and two fonts — and everything below adapts. That is how five sites
   can look genuinely different while sharing one dependable foundation.

   A demo sets its theme by putting this BEFORE the link to this file:

       <style>
         :root {
           --d-bg: #fbf7f2;  --d-surface: #fff;
           --d-ink: #1b1614; --d-muted: #6f6259;
           --d-accent: #b4542c; --d-line: #e6dcd2;
           --d-font: "Fraunces", Georgia, serif;
           --d-sans: "Inter", system-ui, sans-serif;
           --d-radius: 14px; --d-shadow: 0 18px 40px -26px rgba(0,0,0,.35);
         }
       </style>

   MOTION
   Everything animates on opacity and transform only, so it composites on the
   GPU. Demonstrating polished animation on a page that stutters would be
   self-defeating.
   ========================================================================== */

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--d-bg);
  color: var(--d-ink);
  font-family: var(--d-sans);
  font-size: 16px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--d-font);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.022em;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2.1rem, 5.4vw, 3.9rem); }
h2 { font-size: clamp(1.55rem, 3.4vw, 2.4rem); }
h3 { font-size: clamp(1.12rem, 2vw, 1.42rem); }

p { margin: 0 0 1em; }

/* ------------------------------------------------------------- layout */
.d-wrap {
  width: min(1160px, 100% - 44px);
  margin-inline: auto;
}

.d-wrap-narrow { width: min(760px, 100% - 44px); margin-inline: auto; }

.d-section { padding: clamp(58px, 8vw, 118px) 0; }

.d-section-sm { padding: clamp(34px, 5vw, 62px) 0; }

.d-grid { display: grid; gap: 22px; }

/* auto-fit COLLAPSES empty tracks, which means a "three column" grid silently
   becomes four columns on a 1160px wrap - each track is comfortably over the
   260px minimum, so the browser fits an extra one and four demos shipped with
   a 4-up product grid where the brief asked for three. auto-fill keeps the
   tracks, and the max of 3 stops it going wider still.

   Below 900px the minimum wins and it reflows to two, then one. */
.d-grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.d-grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.d-grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

@media (min-width: 900px) {
  .d-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .d-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 900px) and (max-width: 1020px) {
  /* three tracks would be under 260px each here, so let it be two */
  .d-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* TOP-ALIGNED, NOT CENTRED.
   Centred looked right in the hero, where both columns are about the same
   height, and wrong everywhere else: a product thumbnail floated in the middle
   of a much taller buy column, and a short text block hung halfway down beside
   a long card. Every demo that hit this patched it locally with
   align-items:start, which is the signal that the default was wrong.

   A block that genuinely wants centring adds .d-split-center. */
.d-split {
  display: grid;
  gap: clamp(28px, 4vw, 62px);
  grid-template-columns: 1fr;
  align-items: start;
}

.d-split-center { align-items: center; }

@media (min-width: 880px) {
  .d-split { grid-template-columns: 1fr 1fr; }
  .d-split-wide { grid-template-columns: 1.15fr 0.85fr; }
  .d-split-narrow { grid-template-columns: 0.85fr 1.15fr; }
}

.d-center { text-align: center; }
.d-center .d-lede { margin-inline: auto; }

/* --------------------------------------------------------- typography */
.d-eyebrow {
  font-family: var(--d-sans);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--d-accent);
  margin: 0 0 14px;
}

.d-lede {
  font-size: clamp(1.02rem, 1.5vw, 1.18rem);
  line-height: 1.6;
  color: var(--d-muted);
  max-width: 62ch;
}

.d-muted { color: var(--d-muted); }
.d-small { font-size: 0.87rem; }

.d-mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--d-muted);
}

/* ------------------------------------------------------------- header */
.d-head {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--d-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.24s ease, background-color 0.24s ease;
}

.d-head.is-stuck { border-bottom-color: var(--d-line); }

.d-head .d-wrap {
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 68px;
}

.d-logo {
  font-family: var(--d-font);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  text-decoration: none;
  margin-right: auto;
  white-space: nowrap;
}

.d-logo span { color: var(--d-accent); }

.d-nav { display: none; gap: 26px; align-items: center; }

@media (min-width: 820px) { .d-nav { display: flex; } }

.d-nav a {
  text-decoration: none;
  font-size: 0.93rem;
  color: var(--d-muted);
  position: relative;
  padding: 4px 0;
  transition: color 0.18s ease;
}

.d-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.5px;
  background: var(--d-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.24s cubic-bezier(0.16, 0.84, 0.28, 1);
}

.d-nav a:hover { color: var(--d-ink); }
.d-nav a:hover::after,
.d-nav a[aria-current="page"]::after { transform: scaleX(1); }
.d-nav a[aria-current="page"] { color: var(--d-ink); }

.d-head-actions { display: flex; align-items: center; gap: 10px; }

/* ------------------------------------------------------------ buttons */
.d-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  /* Follows the theme. A theme that asks for 4px gets 4px, which is the
     point; one that asks for 16px gets a soft pill rather than a stadium. */
  border-radius: min(var(--d-radius), 14px);
  border: 1px solid transparent;
  background: var(--d-ink);
  color: var(--d-bg);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.16, 0.84, 0.28, 1),
              background-color 0.18s ease, color 0.18s ease,
              border-color 0.18s ease;
}

.d-btn:hover { transform: translate3d(0, -1px, 0); }
.d-btn:active { transform: translate3d(0, 0, 0) scale(0.985); }

.d-btn-accent { background: var(--d-accent); color: #fff; }

.d-btn-ghost {
  background: transparent;
  color: var(--d-ink);
  border-color: var(--d-line);
}
.d-btn-ghost:hover { border-color: var(--d-ink); }

.d-btn-sm { padding: 9px 16px; font-size: 0.85rem; }

.d-btn-block { width: 100%; }

/* --------------------------------------------------------------- card */
.d-card {
  background: var(--d-surface);
  border: 1px solid var(--d-line);
  border-radius: var(--d-radius);
  overflow: hidden;
  transition: transform 0.26s cubic-bezier(0.16, 0.84, 0.28, 1),
              border-color 0.26s ease, box-shadow 0.26s ease;
}

.d-card-pad { padding: 22px; }

.d-card-hover:hover {
  transform: translate3d(0, -4px, 0);
  border-color: color-mix(in srgb, var(--d-ink) 24%, transparent);
  box-shadow: var(--d-shadow);
}

/* a product image area that needs no real photograph */
.d-thumb {
  aspect-ratio: 4 / 5;
  background:
    radial-gradient(circle at 32% 28%,
      color-mix(in srgb, var(--d-accent) 26%, var(--d-surface)),
      var(--d-surface) 72%);
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--d-ink) 42%, transparent);
  font-family: var(--d-font);
  font-size: 1.6rem;
}

.d-thumb-wide { aspect-ratio: 16 / 10; }
.d-thumb-square { aspect-ratio: 1 / 1; }

/* ------------------------------------------------------------- badges */
.d-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: min(var(--d-radius), 10px);
  background: color-mix(in srgb, var(--d-accent) 12%, transparent);
  color: var(--d-accent);
}

.d-price {
  font-family: var(--d-font);
  font-size: 1.32rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.d-price s {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--d-muted);
  margin-left: 8px;
}

/* --------------------------------------------------------------- form */
.d-field { display: grid; gap: 6px; margin-bottom: 16px; }

.d-field label {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.d-field input,
.d-field select,
.d-field textarea {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--d-line);
  border-radius: calc(var(--d-radius) - 4px);
  background: var(--d-surface);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.d-field input:focus,
.d-field select:focus,
.d-field textarea:focus {
  outline: none;
  border-color: var(--d-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--d-accent) 16%, transparent);
}

.d-hint { font-size: 0.78rem; color: var(--d-muted); }

/* the login / signup screens */
.d-auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 22px;
}

.d-auth-card {
  width: min(430px, 100%);
  background: var(--d-surface);
  border: 1px solid var(--d-line);
  border-radius: calc(var(--d-radius) + 6px);
  padding: 36px 32px 30px;
  box-shadow: var(--d-shadow);
}

.d-auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: color-mix(in srgb, var(--d-ink) 5%, transparent);
  border-radius: min(var(--d-radius), 12px);
  margin-bottom: 24px;
}

.d-auth-tabs button {
  padding: 10px;
  border: 0;
  border-radius: calc(min(var(--d-radius), 12px) - 2px);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--d-muted);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.d-auth-tabs button[aria-selected="true"] {
  background: var(--d-surface);
  color: var(--d-ink);
  box-shadow: 0 2px 8px -4px rgba(0, 0, 0, 0.3);
}

.d-auth-alt {
  margin-top: 16px;
  font-size: 0.86rem;
  color: var(--d-muted);
  text-align: center;
}

.d-auth-social {
  display: grid;
  gap: 9px;
  margin-bottom: 20px;
}

.d-auth-social button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--d-line);
  border-radius: calc(var(--d-radius) - 4px);
  background: var(--d-surface);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease;
}

.d-auth-social button:hover { border-color: var(--d-ink); }

.d-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  font-size: 0.76rem;
  color: var(--d-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.d-or::before, .d-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--d-line);
}

/* -------------------------------------------------------------- table */
.d-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }

.d-table th, .d-table td {
  text-align: left;
  padding: 13px 12px;
  border-bottom: 1px solid var(--d-line);
}

.d-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--d-muted);
  font-weight: 700;
}

/* --------------------------------------------------------------- misc */
.d-note {
  border-left: 3px solid var(--d-accent);
  padding: 14px 18px;
  background: color-mix(in srgb, var(--d-accent) 6%, transparent);
  border-radius: 0 var(--d-radius) var(--d-radius) 0;
  font-size: 0.92rem;
}

.d-tags { display: flex; flex-wrap: wrap; gap: 7px; }

.d-tags span {
  font-size: 0.75rem;
  padding: 5px 11px;
  border: 1px solid var(--d-line);
  border-radius: min(var(--d-radius), 10px);
  color: var(--d-muted);
}

.d-stars { color: var(--d-accent); letter-spacing: 2px; font-size: 0.9rem; }

.d-quote {
  font-family: var(--d-font);
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  line-height: 1.45;
  letter-spacing: -0.015em;
}

.d-foot {
  border-top: 1px solid var(--d-line);
  padding: 44px 0 34px;
  font-size: 0.88rem;
  color: var(--d-muted);
}

.d-foot-grid {
  display: grid;
  gap: 26px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.d-foot-grid h4 {
  font-family: var(--d-sans);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--d-ink);
  margin-bottom: 10px;
}

.d-foot-grid a { display: block; text-decoration: none; padding: 3px 0; }
.d-foot-grid a:hover { color: var(--d-ink); }

.d-foot-bottom {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--d-line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  font-size: 0.82rem;
}

/* the badge that links back to the gallery */
.d-demo-badge {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 999px;
  background: #0e0e11;
  color: #f7f3ec;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s cubic-bezier(0.16, 0.84, 0.28, 1);
}

.d-demo-badge:hover { transform: translate3d(0, -2px, 0); }

@media (max-width: 600px) {
  .d-demo-badge { right: 10px; bottom: 10px; font-size: 0.72rem; padding: 8px 12px; }
}

/* ==========================================================================
   Motion
   ========================================================================== */

.d-rise {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  animation: d-rise 0.72s cubic-bezier(0.16, 0.84, 0.28, 1) both;
}

@keyframes d-rise {
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.d-rise-1 { animation-delay: 0.06s; }
.d-rise-2 { animation-delay: 0.14s; }
.d-rise-3 { animation-delay: 0.22s; }
.d-rise-4 { animation-delay: 0.30s; }

/* revealed as you scroll to it */
.d-reveal {
  opacity: 0;
  transform: translate3d(0, 22px, 0);
  transition: opacity 0.66s cubic-bezier(0.16, 0.84, 0.28, 1),
              transform 0.66s cubic-bezier(0.16, 0.84, 0.28, 1);
}

.d-reveal.is-in { opacity: 1; transform: none; }

/* children arrive one after another */
.d-stagger > * {
  opacity: 0;
  transform: translate3d(0, 16px, 0);
  transition: opacity 0.56s cubic-bezier(0.16, 0.84, 0.28, 1),
              transform 0.56s cubic-bezier(0.16, 0.84, 0.28, 1);
}

.d-stagger.is-in > * { opacity: 1; transform: none; }
.d-stagger.is-in > *:nth-child(1) { transition-delay: 0.04s; }
.d-stagger.is-in > *:nth-child(2) { transition-delay: 0.10s; }
.d-stagger.is-in > *:nth-child(3) { transition-delay: 0.16s; }
.d-stagger.is-in > *:nth-child(4) { transition-delay: 0.22s; }
.d-stagger.is-in > *:nth-child(5) { transition-delay: 0.28s; }
.d-stagger.is-in > *:nth-child(6) { transition-delay: 0.34s; }
.d-stagger.is-in > *:nth-child(n+7) { transition-delay: 0.38s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .d-rise,
  .d-reveal,
  .d-stagger > * {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .d-btn:hover,
  .d-card-hover:hover,
  .d-demo-badge:hover { transform: none; }
}

@media print {
  .d-head, .d-demo-badge { display: none !important; }
  .d-rise, .d-reveal, .d-stagger > * {
    opacity: 1 !important;
    transform: none !important;
  }
}
