/* nanju.co, dark warm hero + tiles
   palette sampled from Nan's portrait: mahogany #1A0D0B, camel #C9A075, burgundy #6B3A3C */
:root {
  --bg: #1a0d0b;
  --bg2: #241310;
  --tile: #2b1713;
  --line: #4a2d27;
  --text: #f7ebe2;
  --muted: #d6c2b5;
  --camel: #c9a075;
  --camel-deep: #a17f5f;
  --on-camel: #2b1713;
  --on-camel-muted: #4a3222;
  --font-display: "Baloo 2", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", "Noto Sans Thai", system-ui, sans-serif;
  --r-sm: 6px;
  --r-md: 12px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; cursor: pointer; text-decoration: none; }
a:focus-visible { outline: 3px solid var(--camel); outline-offset: 3px; border-radius: 2px; }
h1, h2 { font-family: var(--font-display); line-height: 1.1; text-wrap: balance; }
p { text-wrap: pretty; }
ul, ol { list-style: none; padding: 0; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

/* Header: sticks to the top; full-bleed background so content never shows behind it */
.top { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; margin: 0 -24px; padding: 16px 24px; background: color-mix(in oklab, var(--bg) 94%, transparent); border-bottom: 1px solid transparent; transition: border-color .3s var(--ease-out); }
@supports not (background: color-mix(in oklab, red, blue)) { .top { background: var(--bg); } }
.top.scrolled { border-color: var(--line); }
.hero, .grid, #talks, #demos { scroll-margin-top: 88px; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 22px; }
.pill { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg2); }
.pill a { padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 15px; color: var(--muted); transition: color .25s var(--ease-out), background-color .25s var(--ease-out); }
.pill a:hover { color: var(--text); }
.pill a.on { background: var(--tile); color: var(--text); }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  padding-top: 16px;
}
.hero-left, .hero-right { padding-bottom: 64px; }
.hi { font-family: var(--font-display); font-weight: 700; color: var(--camel); font-size: 18px; }
h1 { font-size: clamp(2.1rem, 1.3rem + 2.6vw, 3.2rem); font-weight: 800; margin-top: 6px; letter-spacing: -0.01em; }
h1 .w { display: inline-block; }
.lede { margin-top: 14px; color: var(--muted); max-width: 34ch; }
.btns { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px; border-radius: var(--r-sm);
  font-weight: 700; border: 2px solid var(--camel); color: var(--camel);
  transition: background-color .25s var(--ease-out), color .25s var(--ease-out);
}
.btn svg { width: 18px; height: 18px; transition: transform .3s var(--ease-out); }
.btn:hover { background: var(--camel); color: var(--on-camel); }
.btn.solid { background: var(--camel); color: var(--on-camel); }
.btn.solid:hover { background: var(--text); border-color: var(--text); }
.btn.solid:hover svg { transform: translate(2px, -2px); }

.portrait { position: relative; align-self: end; aspect-ratio: 3 / 4; overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent),
                      linear-gradient(to bottom, transparent, #000 12%, #000 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent),
              linear-gradient(to bottom, transparent, #000 12%, #000 100%);
  mask-composite: intersect;
}
.layer { position: absolute; inset: 0; will-change: transform; }
.layer img { width: 100%; height: 100%; object-fit: cover; }
/* --px/--py are set by main.js from the pointer; both default to 0 */
.layer.bg { transform: translate3d(calc(var(--px, 0) * -8px), calc(var(--py, 0) * -5px), 0) scale(1.08); }
.layer.fg { transform: translate3d(calc(var(--px, 0) * 10px), calc(var(--py, 0) * 6px), 0); transform-origin: 50% 85%; }
.layer.bg, .layer.fg { transition: transform .6s var(--ease-out); }


/* Cat blink: two fur-coloured lids over the eyes, scaled closed for a moment every few seconds */
.blink { position: absolute; width: 4.6%; height: 4.2%; border-radius: 50%; background: #1d1a1d; transform: scaleY(0); transform-origin: 50% 50%; }
.blink.l { left: 42.9%; top: 61.8%; }
.blink.r { left: 51.4%; top: 61.8%; }

.dust { position: absolute; left: var(--x); bottom: 10%; width: 5px; height: 5px; border-radius: 50%; background: #f6d3bd; opacity: 0; }

.hero-right h2 { font-size: 26px; font-weight: 800; }
.hero-right p { margin-top: 10px; color: var(--muted); max-width: 34ch; }
.tag { font-family: var(--font-display); font-weight: 700; color: var(--camel); font-size: 19px; }
.social { display: flex; gap: 10px; margin-top: 22px; }
.social a { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; background: var(--bg2); transition: background-color .25s var(--ease-out), border-color .25s var(--ease-out); }
.social a:hover { background: var(--camel); border-color: var(--camel); }
.social svg { width: 20px; height: 20px; color: var(--camel); transition: color .25s var(--ease-out); }
.social a:hover svg { color: var(--on-camel); }

/* Tiles */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 8px 0 56px; align-items: stretch; }
.tile { background: var(--tile); border: 1px solid var(--line); border-radius: var(--r-md); padding: 22px; min-width: 0; }
.tile.wide { grid-column: 1 / -1; }
.tile h2 { font-size: 19px; font-weight: 800; margin-bottom: 10px; }
.tile.camel { background: var(--camel); border-color: transparent; color: var(--on-camel); }
.m { color: var(--muted); font-size: 15px; }
.camel .m { color: var(--on-camel-muted); }

/* Demo library: three equal cards in one wide tile */
.demos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.demos a { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); height: 100%; transition: border-color .25s var(--ease-out), background-color .25s var(--ease-out); }
.demos a:hover { border-color: var(--camel); background: var(--bg); }
.demos svg { width: 20px; height: 20px; color: var(--camel); flex: none; margin-top: 2px; }
.demos span { flex: 1; min-width: 0; }
.demos b { display: block; font-family: var(--font-display); font-size: 16px; line-height: 1.25; }
.demos small { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.45; margin-top: 4px; }
.demos .go { width: 16px; height: 16px; transition: transform .3s var(--ease-out); }
.demos a:hover .go { transform: translate(2px, -2px); }

.list li { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.list li:first-child { border-top: 0; padding-top: 0; }
.list .when { font-weight: 700; color: var(--camel); padding-top: 2px; }
.list b { display: block; font-family: var(--font-display); font-size: 16px; line-height: 1.25; }

/* Certification case */
.t-certs { text-align: center; display: flex; flex-direction: column; }
.t-certs h2, .t-certs .m { text-align: left; }
.t-certs .more { align-self: center; flex: none; }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin-top: 14px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg2); }
.seg button { font: inherit; font-weight: 700; font-size: 12.5px; color: var(--muted); background: transparent; border: 0; border-radius: 999px; padding: 6px 4px; cursor: pointer; transition: color .25s var(--ease-out), background-color .25s var(--ease-out); white-space: nowrap; min-width: 0; }
.seg button span { color: var(--camel); margin-left: 2px; }
.seg button:hover { color: var(--text); }
.seg button[aria-selected="true"] { background: var(--tile); color: var(--text); }
.seg button:focus-visible { outline: 3px solid var(--camel); outline-offset: 2px; }
.case { flex: 1 1 auto; min-height: 0; max-height: 336px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; align-content: start; margin-top: 14px; padding: 16px 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; }
.case li { font-size: 13px; line-height: 1.3; }
.case .slot {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto 8px;
  background: var(--bg); display: grid; place-items: center;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, .6), inset 0 -1px 0 rgba(201, 160, 117, .25);
  transition: transform .3s var(--ease-out);
}
.case li:hover .slot { transform: translateY(-3px); }
.case .slot img { width: 66px; height: 66px; }
.case b { display: block; font-family: var(--font-display); font-size: 13px; }
.case small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.case.dealing li { opacity: 0; transform: translateY(10px); }
.case li { transition: opacity .3s var(--ease-out), transform .3s var(--ease-out); }
.more { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; font-weight: 700; font-size: 14px; color: var(--camel); border-bottom: 2px solid transparent; transition: border-color .25s var(--ease-out); }
.more:hover { border-color: var(--camel); }
.more svg { width: 16px; height: 16px; transition: transform .3s var(--ease-out); }
.more:hover svg { transform: translateX(4px); }
.chip { background: var(--camel); color: var(--on-camel); border-radius: 999px; padding: 2px 10px; font-family: var(--font-display); font-weight: 800; font-size: 15px; }

.rows a { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); font-weight: 700; font-size: 15px; transition: color .25s var(--ease-out); }
.rows li:first-child a { border-top: 0; padding-top: 0; }
.rows a:hover { color: var(--camel); }
.rows svg { width: 18px; height: 18px; color: var(--camel); flex: none; }
.rows small { display: block; font-weight: 600; font-size: 13px; color: var(--muted); line-height: 1.4; }

footer { text-align: center; color: var(--muted); font-size: 14px; padding-bottom: 32px; }

/* Motion. Everything is visible without it; these only add the entrance. */
@media (prefers-reduced-motion: no-preference) {
  @keyframes settle { from { opacity: 0; transform: translateY(14px); } }
  @keyframes rise { from { opacity: 0; transform: translateY(24px); } }
  @keyframes fadein { from { opacity: 0; } }
  @keyframes float { from { translate: 0 0; } to { translate: 0 -6px; } }
  @keyframes breathe { from { scale: 1; } to { scale: 1.015; } }
  @keyframes drift {
    0%   { opacity: 0; transform: translate(0, 0); }
    15%  { opacity: .8; }
    85%  { opacity: .4; }
    100% { opacity: 0; transform: translate(14px, -260px); }
  }
  @keyframes blink { 0%, 92%, 100% { transform: scaleY(0); } 95%, 97% { transform: scaleY(1); } }

  .hi, .lede, .btns, .hero-right h2, .hero-right p, .social { animation: settle .7s var(--ease-out) both; }
  h1 .w { animation: settle .7s var(--ease-out) both; animation-delay: calc(.1s + var(--i) * 70ms); }
  .lede { animation-delay: .55s; }
  .btns { animation-delay: .65s; }
  .hero-right h2 { animation-delay: .3s; }
  .hero-right p { animation-delay: .4s; }
  .social { animation-delay: .55s; }
  .layer.bg { animation: fadein 1.2s var(--ease-out) both; }
  .layer.fg { animation: rise .9s var(--ease-out) both .15s; }
  .layer.fg img { animation: float 5s ease-in-out infinite alternate, breathe 9s ease-in-out infinite alternate; transform-origin: 50% 85%; }
  .blink { animation: blink 6s linear infinite; }
  .blink.r { animation-delay: .02s; }
  .dust { animation: drift 9s linear infinite; animation-delay: var(--d); }
  .tile.in { animation: settle .6s var(--ease-out) both; }
  .tile.in:nth-child(2) { animation-delay: .08s; }
  .tile.in:nth-child(3) { animation-delay: .16s; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}

/* Responsive */
@media (max-width: 1140px) and (min-width: 961px) {
  h1 { font-size: clamp(1.8rem, 0.6rem + 2.2vw, 2.5rem); }
  .lede { font-size: 16px; }
}
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: 8px; text-align: center; }
  .hero-left { order: 1; padding-bottom: 24px; }
  .portrait { order: 2; width: min(380px, 100%); justify-self: center; margin: 0; }
  .hero-right { order: 3; padding: 32px 0 40px; }
  .lede, .hero-right p { margin-left: auto; margin-right: auto; }
  .btns, .social { justify-content: center; }
  .grid { grid-template-columns: 1fr; }
  .demos { grid-template-columns: 1fr; }
  .case { max-height: none; }
}
@media (max-width: 480px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .top { flex-wrap: wrap; gap: 10px; margin: 0 -16px; padding: 12px 16px; }
  .pill a { padding: 7px 13px; font-size: 14px; }
  .btn { width: 100%; justify-content: center; }
  .case { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list li { grid-template-columns: 1fr; gap: 2px; }
}
