/* ==========================================================================
   Krynexis AI — base
   Tokens, reset, typography, paper system, grain, reveal
   ========================================================================== */

@property --lift {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

:root {
  /* Paper stock */
  --paper: #F1EDE4;
  --paper-hi: #F8F5EE;
  --bone: #E6E0D3;
  --bone-2: #D9D1C1;
  --kraft: #C8B596;
  --kraft-2: #A8936F;

  /* Ink */
  --ink: #15140F;
  --ink-2: #3B3930;
  --mute: #77715F;
  --line: rgba(21, 20, 15, 0.14);
  --line-2: rgba(21, 20, 15, 0.24);

  /* Black card stock */
  --black: #121210;
  --black-2: #1D1C19;
  --black-3: #2A2925;

  /* Riso pair */
  --signal: #FF4A1C;
  --signal-deep: #D9360D;
  --signal-soft: #FFDCCF;
  --cobalt: #2B45FF;
  --cobalt-deep: #1A2BC4;
  --cobalt-soft: #DADFFF;

  /* Light source (driven by JS) */
  --sx: 0.5;
  --sy: 1.1;
  --px: 0;
  --py: 0;
  --scroll: 0;

  /* Type */
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-paper: cubic-bezier(.2, 1.15, .32, 1);
  --ease-in: cubic-bezier(.7, 0, .84, 0);

  /* Layout */
  --gutter: clamp(20px, 4vw, 56px);
  --maxw: 1320px;
  --nav-h: 64px;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
::selection { background: var(--signal); color: var(--paper-hi); }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: fixed; left: 12px; top: -60px; z-index: 10001;
  background: var(--ink); color: var(--paper); padding: 10px 14px; font-family: var(--mono); font-size: 13px;
}
.skip:focus { top: 12px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- grain: fibres + tooth, fixed over everything ---------- */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  opacity: .55;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .09 0 0 0 0 .08 0 0 0 0 .05 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .09' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .25 0 0 0 0 .15 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
}

/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.section {
  position: relative;
  padding-block: clamp(80px, 9vw, 136px);
}
.section--tight { padding-block: clamp(64px, 8vw, 112px); }

/* ---------- type ---------- */
.display {
  font-size: clamp(48px, 6.7vw, 112px);
  line-height: .92;
  letter-spacing: -.052em;
  font-weight: 600;
  text-wrap: balance;
}
.h1 {
  font-size: clamp(44px, 6.6vw, 104px);
  line-height: .93;
  letter-spacing: -.048em;
  font-weight: 600;
  text-wrap: balance;
}
.h2 {
  font-size: clamp(38px, 5.2vw, 78px);
  line-height: .96;
  letter-spacing: -.042em;
  font-weight: 600;
  text-wrap: balance;
}
.h3 {
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1.08;
  letter-spacing: -.03em;
  font-weight: 600;
}
.h4 {
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: -.015em;
  font-weight: 600;
}
.display em, .h1 em, .h2 em, .h3 em, .serif {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 350;
  letter-spacing: -.025em;
}
.lede {
  font-size: clamp(17px, 1.35vw, 20px);
  line-height: 1.5;
  color: var(--ink-2);
  max-width: 38ch;
  text-wrap: pretty;
}
.body { color: var(--ink-2); text-wrap: pretty; }
.small { font-size: 14px; line-height: 1.5; color: var(--mute); }
.mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.eyebrow::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--signal);
  box-shadow: 1.5px 1.5px 0 var(--ink);
}
.eyebrow b {
  font-weight: 500;
  padding: 3px 6px 2px;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  color: var(--ink);
}
.eyebrow--cobalt::before { background: var(--cobalt); }
.on-black .eyebrow { color: #BDB7A6; }
.on-black .eyebrow b { color: var(--paper); border-color: rgba(241,237,228,.25); }
.on-black .eyebrow::before { box-shadow: 1.5px 1.5px 0 var(--paper); }

/* riso misregistration accent */
.riso {
  position: relative;
  color: var(--ink);
  text-shadow: -.035em .02em 0 rgba(43, 69, 255, .0), .035em -.02em 0 rgba(255, 74, 28, .0);
  transition: text-shadow .5s var(--ease);
}
.riso:hover, .riso.is-live {
  text-shadow: -.03em .018em 0 rgba(43, 69, 255, .55), .03em -.018em 0 rgba(255, 74, 28, .7);
}

/* ---------- paper system ----------
   --z  = resting height of the sheet
   --lift = extra height (hover / drag / placing), animatable via @property
   shadows follow the global light (--sx / --sy)                                  */
.paper {
  --z: 2;
  --h: calc(var(--z) + var(--lift));
  position: relative;
  background: var(--paper-hi);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .7),
    0 0 0 .5px rgba(21, 20, 15, .10),
    calc(var(--sx) * var(--h) * .45px) calc(var(--sy) * var(--h) * .45px) calc(var(--h) * .55px) rgba(21, 20, 15, .16),
    calc(var(--sx) * var(--h) * 2.2px) calc(var(--sy) * var(--h) * 2.2px) calc(var(--h) * 4.2px) rgba(21, 20, 15, .10);
}
.paper--bone { background: var(--bone); }
.paper--kraft { background: var(--kraft); }
.paper--signal { background: var(--signal); color: var(--paper-hi); }
.paper--cobalt { background: var(--cobalt); color: var(--paper-hi); }
.paper--ink {
  background: var(--black-2);
  color: var(--paper);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .07),
    0 0 0 .5px rgba(0, 0, 0, .4),
    calc(var(--sx) * var(--h) * .45px) calc(var(--sy) * var(--h) * .45px) calc(var(--h) * .55px) rgba(0, 0, 0, .35),
    calc(var(--sx) * var(--h) * 2.2px) calc(var(--sy) * var(--h) * 2.2px) calc(var(--h) * 4.2px) rgba(0, 0, 0, .25);
}

/* a hole cut into the sheet: inner shadow follows the light */
.cut {
  box-shadow:
    inset calc(var(--sx) * 3px) calc(var(--sy) * 3.5px) 7px rgba(21, 20, 15, .28),
    inset calc(var(--sx) * .8px) calc(var(--sy) * 1px) 0 rgba(21, 20, 15, .2);
}

/* ---------- print marks ---------- */
.marks { position: relative; }
.marks::before {
  content: '';
  position: absolute;
  inset: -14px;
  pointer-events: none;
  opacity: .55;
  background:
    linear-gradient(var(--ink), var(--ink)) left 0 top 13px / 9px 1px no-repeat,
    linear-gradient(var(--ink), var(--ink)) left 13px top 0 / 1px 9px no-repeat,
    linear-gradient(var(--ink), var(--ink)) right 0 top 13px / 9px 1px no-repeat,
    linear-gradient(var(--ink), var(--ink)) right 13px top 0 / 1px 9px no-repeat,
    linear-gradient(var(--ink), var(--ink)) left 0 bottom 13px / 9px 1px no-repeat,
    linear-gradient(var(--ink), var(--ink)) left 13px bottom 0 / 1px 9px no-repeat,
    linear-gradient(var(--ink), var(--ink)) right 0 bottom 13px / 9px 1px no-repeat,
    linear-gradient(var(--ink), var(--ink)) right 13px bottom 0 / 1px 9px no-repeat;
}
.on-black .marks::before, .marks--light::before {
  background:
    linear-gradient(var(--paper), var(--paper)) left 0 top 13px / 9px 1px no-repeat,
    linear-gradient(var(--paper), var(--paper)) left 13px top 0 / 1px 9px no-repeat,
    linear-gradient(var(--paper), var(--paper)) right 0 top 13px / 9px 1px no-repeat,
    linear-gradient(var(--paper), var(--paper)) right 13px top 0 / 1px 9px no-repeat,
    linear-gradient(var(--paper), var(--paper)) left 0 bottom 13px / 9px 1px no-repeat,
    linear-gradient(var(--paper), var(--paper)) left 13px bottom 0 / 1px 9px no-repeat,
    linear-gradient(var(--paper), var(--paper)) right 0 bottom 13px / 9px 1px no-repeat,
    linear-gradient(var(--paper), var(--paper)) right 13px bottom 0 / 1px 9px no-repeat;
  opacity: .35;
}

.reg {
  width: 22px; height: 22px;
  color: var(--ink);
  opacity: .6;
}

.cutline {
  position: relative;
  height: 1px;
  border: 0;
  margin: 0;
  background-image: linear-gradient(90deg, var(--line-2) 0 6px, transparent 6px 11px);
  background-size: 11px 1px;
}
.cutline::before {
  content: '';
  position: absolute;
  left: 0; top: -7px;
  width: 16px; height: 14px;
  background: var(--paper);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.6'%3E%3Ccircle cx='6' cy='6' r='3'/%3E%3Ccircle cx='6' cy='18' r='3'/%3E%3Cpath d='M8.2 8 20 18M8.2 16 20 6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.6'%3E%3Ccircle cx='6' cy='6' r='3'/%3E%3Ccircle cx='6' cy='18' r='3'/%3E%3Cpath d='M8.2 8 20 18M8.2 16 20 6'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  background-color: var(--ink-2);
}

.colorbar {
  display: inline-flex;
  align-items: stretch;
  height: 14px;
  border: .5px solid var(--line-2);
}
.colorbar i { width: 14px; display: block; }
.colorbar i:nth-child(1) { background: var(--paper-hi); }
.colorbar i:nth-child(2) { background: var(--bone); }
.colorbar i:nth-child(3) { background: var(--kraft); }
.colorbar i:nth-child(4) { background: var(--signal); }
.colorbar i:nth-child(5) { background: var(--cobalt); }
.colorbar i:nth-child(6) { background: var(--ink); }

/* ---------- reveal: sheets are *placed*, not faded ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translate3d(0, 30px, 0) rotate(-1.1deg);
  --lift: 12;
  transition:
    opacity .6s var(--ease) calc(var(--d, 0) * 80ms),
    transform 1s var(--ease-paper) calc(var(--d, 0) * 80ms),
    --lift 1.1s var(--ease) calc(var(--d, 0) * 80ms);
}
.js [data-reveal="right"] { transform: translate3d(36px, 0, 0) rotate(1.4deg); }
.js [data-reveal="fade"] { transform: none; }
.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
  --lift: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
  }
  .js [data-reveal] { opacity: 1; transform: none; }
}
