/* ==========================================================================
   NinjApps — shared site theme
   Precision-instrument direction: rigorous rules, tight grotesque headings,
   monospace for technical detail. Light and dark aware. Self-hosted fonts so
   no visitor IP is handed to a third party.
   Single source of truth — every page links this file. Edit here, not inline.
   ========================================================================== */

/* --- Fonts (latin subset, self-hosted) ---------------------------------- */
@font-face {
  font-family: 'Archivo';
  src: url('fonts/archivo-400_700-latin.woff2') format('woff2');
  font-weight: 400 700;               /* variable axis */
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('fonts/plexmono-400-latin.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Plex Mono';
  src: url('fonts/plexmono-500-latin.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}

/* --- Tokens -------------------------------------------------------------- */
:root {
  --ground:  #F7F5F1;
  --surface: #FFFFFF;
  --ink:     #14120F;
  --ink-2:   #5A544C;
  --rule:    #E0DAD1;
  --accent:  #C4400C;
  --accent-ink: #FFFFFF;

  --sans: 'Archivo', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* 4px base, 1.25 type ratio */
  --s1: 0.5rem;  --s2: 0.75rem; --s3: 1rem;   --s4: 1.5rem;
  --s5: 2rem;    --s6: 3rem;    --s7: 4.5rem; --s8: 7rem;

  --measure: 68ch;
  --shell: 68rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:  #100F0D;
    --surface: #191713;
    --ink:     #F4F0E9;
    --ink-2:   #9E968B;
    --rule:    #2C2822;
    --accent:  #FF7038;
    --accent-ink: #16130F;
  }
}

/* --- Reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
}

/* Grain — atmosphere without an image request. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: reduce) { body::after { display: none; } }

/* --- Shell --------------------------------------------------------------- */
.shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--s4);
}
@media (min-width: 48rem) { .shell { padding: 0 var(--s6); } }

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--s2) var(--s3);
  font: 500 0.8rem/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  z-index: 10000;
}
.skip:focus { left: var(--s3); top: var(--s3); }

/* --- Masthead ------------------------------------------------------------ */
.masthead {
  border-bottom: 1px solid var(--rule);
}
.masthead > .shell {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2) var(--s4);
  padding-top: var(--s4);
  padding-bottom: var(--s4);
}
.wordmark {
  font: 700 1.0625rem/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}
.wordmark:hover { color: var(--accent); }
.wordmark .mark { color: var(--accent); }

.nav {
  display: flex;
  gap: var(--s4);
  font: 400 0.8125rem/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.nav a { color: var(--ink-2); text-decoration: none; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--accent); }
.nav a[aria-current='page'] { font-weight: 500; }

/* --- Typography ---------------------------------------------------------- */
h1, h2, h3 { font-family: var(--sans); font-weight: 700; }

.display {
  font-size: clamp(2.25rem, 6.2vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0 0 var(--s4);
  max-width: 22ch;
  text-wrap: balance;
}

h1.page-title {
  font-size: clamp(1.875rem, 4vw, 2.75rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0 0 var(--s2);
}

h2 {
  font-size: 1.25rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
  margin: var(--s6) 0 var(--s2);
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin: var(--s4) 0 var(--s1);
}

p, ul, ol { margin: 0 0 var(--s3); max-width: var(--measure); }
li { margin-bottom: var(--s1); }
strong { font-weight: 700; }

.lede {
  font-size: 1.1875rem;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 46ch;
}

.eyebrow {
  font: 500 0.75rem/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 var(--s4);
  display: block;
}

.mono { font-family: var(--mono); font-size: 0.875rem; }

a { color: var(--accent); text-decoration: none; }
/* Underline only body-copy links on hover; chrome and buttons stay clean. */
main p a:hover, main li a:hover, .panel a:hover, .legal a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.store:hover, .wordmark:hover, .nav a:hover, .foot a:hover { text-decoration: none; }

:where(a, button, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* --- Sections ------------------------------------------------------------ */
.hero { padding: var(--s7) 0 var(--s6); }
.section { padding: var(--s6) 0; border-top: 1px solid var(--rule); }
.section:first-of-type { border-top: 0; }

.section-label {
  font: 500 0.75rem/1 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 var(--s4);
}

/* --- App index (numbered rows) ------------------------------------------- */
.index { list-style: none; margin: 0; padding: 0; max-width: none; }

.index > li {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: var(--s2) var(--s3);
  padding: var(--s4) 0;
  border-top: 1px solid var(--rule);
  margin: 0;
}
.index > li:last-child { border-bottom: 1px solid var(--rule); }

@media (min-width: 46rem) {
  .index > li {
    grid-template-columns: 3rem minmax(0, 1fr) auto;
    align-items: baseline;
  }
}

.index .num {
  font: 500 0.8125rem/1.6 var(--mono);
  color: var(--accent);
  letter-spacing: 0.04em;
}
.index .name {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.125rem;
  max-width: none;
}
.index .desc { color: var(--ink-2); margin: 0; font-size: 0.9375rem; max-width: 52ch; }
.index .coord {
  font: 400 0.8125rem/1.6 var(--mono);
  color: var(--ink-2);
  margin: var(--s1) 0 0;
  max-width: none;
}

.stores {
  display: flex;
  gap: var(--s1);
  grid-column: 2;
  margin-top: var(--s2);
}
@media (min-width: 46rem) {
  .stores { grid-column: 3; margin-top: 0; }
}
.store {
  font: 500 0.75rem/1 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  border: 1px solid var(--rule);
  padding: 0.5625rem 0.75rem;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  transition: border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.store:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  text-decoration: none;
}

/* --- Contact panel ------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: var(--s4);
  max-width: var(--measure);
}
@media (min-width: 46rem) { .panel { padding: var(--s5); } }
.panel > :last-child { margin-bottom: 0; }

.panel .addr {
  font: 500 clamp(1.0625rem, 2.4vw, 1.375rem)/1.3 var(--mono);
  letter-spacing: -0.01em;
  margin: 0 0 var(--s2);
  word-break: break-word;
}
.panel .note { color: var(--ink-2); font-size: 0.9375rem; margin: 0; }

/* --- FAQ ----------------------------------------------------------------- */
.faq { border-top: 1px solid var(--rule); }
.faq > div {
  border-bottom: 1px solid var(--rule);
  padding: var(--s4) 0;
}
.faq h3 { margin: 0 0 var(--s1); }
.faq > div > :last-child { margin-bottom: 0; }

/* --- Legal (long-form) --------------------------------------------------- */
.legal { max-width: var(--measure); }
.legal h2 {
  font-size: 1.0625rem;
  margin: var(--s5) 0 var(--s2);
  padding-top: var(--s4);
  border-top: 1px solid var(--rule);
}
.legal h2:first-of-type { margin-top: var(--s4); }
.legal .effective {
  font: 400 0.8125rem/1.6 var(--mono);
  color: var(--ink-2);
  letter-spacing: 0.02em;
}

/* --- Footer -------------------------------------------------------------- */
.foot {
  border-top: 1px solid var(--rule);
  margin-top: var(--s7);
}
.foot > .shell {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
  justify-content: space-between;
  align-items: baseline;
  padding-top: var(--s4);
  padding-bottom: var(--s6);
  font: 400 0.8125rem/1.6 var(--mono);
  color: var(--ink-2);
}
.foot a { color: var(--ink-2); }
.foot a:hover { color: var(--accent); }
.foot nav { display: flex; gap: var(--s4); flex-wrap: wrap; }

/* --- Entrance (one orchestrated reveal, not scattered micro-motion) ------ */
@media (prefers-reduced-motion: no-preference) {
  .rise {
    animation: rise 0.62s cubic-bezier(0.16, 0.84, 0.24, 1) both;
  }
  .rise:nth-child(1) { animation-delay: 0.02s; }
  .rise:nth-child(2) { animation-delay: 0.10s; }
  .rise:nth-child(3) { animation-delay: 0.18s; }
  .rise:nth-child(4) { animation-delay: 0.26s; }
  .rise:nth-child(5) { animation-delay: 0.34s; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(0.75rem); }
    to   { opacity: 1; transform: none; }
  }
}

/* --- Print (legal pages get read and filed) ------------------------------ */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  body::after, .masthead .nav, .skip { display: none; }
  a { color: #000; text-decoration: underline; }
  .legal h2 { break-after: avoid; }
}
