@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("/assets/fonts/space-grotesk.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #121212;
  --bg-raised: #191817;
  --fg: #e8e1d7;
  --muted: #a7a199;
  --gray: #4a4a4a;
  --line: rgba(232, 225, 215, 0.2);
  --line-strong: rgba(232, 225, 215, 0.42);
  --orange: #ff6a00;
  --orange-soft: #ef893b;
  --error: #ff8f7a;
  --paper: #ddd2c4;
  --ink: #171614;
  --font-body: "Inter", system-ui, sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --gutter: clamp(1.25rem, 3vw, 2.5rem);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .9 0 0 0 0 .88 0 0 0 0 .84 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  color: var(--fg);
  font-family: var(--font-body);
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
}

main { width: 100%; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--grain);
  opacity: 0.07;
  pointer-events: none;
}

::selection { background: var(--orange); color: var(--ink); }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

h1, h2, .hero-title { font-family: var(--font-display); font-weight: 500; }

/* Top bar */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--fg);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
}

/* The logo PNG is flat white on transparent, so it works as a mask for any ink. */
.logo-mark {
  display: inline-block;
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  background: var(--orange);
  -webkit-mask: url("/assets/img/icon.png") center / contain no-repeat;
  mask: url("/assets/img/icon.png") center / contain no-repeat;
}

.topbar-menu { position: relative; }

.topbar-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: transparent;
  border: 0;
  color: var(--fg);
  padding: 0.6rem 0;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

.topbar-menu-btn svg { width: 1rem; height: 1rem; stroke-width: 1.5; }
.topbar-menu-btn .chevron { transition: transform 0.2s ease; }
.topbar-menu-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.topbar-menu-btn:hover,
.topbar-menu-btn[aria-expanded="true"] { color: var(--orange); }

.topbar-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: min(340px, calc(100vw - 2 * var(--gutter)));
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
}

.topbar-menu-dropdown a {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 1rem;
  text-decoration: none;
  color: var(--fg);
}

.topbar-menu-dropdown a + a { border-top: 1px solid var(--line); }
.topbar-menu-dropdown a:hover strong { color: var(--orange); }
.topbar-menu-dropdown a svg { width: 1.35rem; height: 1.35rem; margin-top: 0.1rem; flex-shrink: 0; stroke-width: 1.25; }
.topbar-menu-dropdown strong { display: block; font-size: 0.92rem; font-weight: 500; color: var(--orange-soft); }
.topbar-menu-dropdown small { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }
.topbar-menu-dropdown .empty { color: var(--muted); font-size: 0.85rem; padding: 1rem; margin: 0; }

/* Home hero: three flush cells, like a brand board */
.hero {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid var(--line);
}

.hero-board {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr) minmax(0, 1.1fr);
  min-height: clamp(320px, 44vh, 460px);
}

.hero-cell { position: relative; overflow: hidden; }
.hero-cell + .hero-cell { border-left: 1px solid var(--line); }

.hero-brand {
  display: flex;
  align-items: center;
  padding: 2.5rem var(--gutter);
}

.hero-moon {
  position: absolute;
  top: -22%;
  right: -22%;
  width: min(68%, 600px);
  aspect-ratio: 1;
  background: url("/assets/img/moon.webp") center / contain no-repeat;
  opacity: 0.85;
}

.hero-stars {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 46%;
  stroke: var(--gray);
  stroke-width: 0.6;
  fill: var(--muted);
}

.hero-text { position: relative; }

.hero-title {
  font-size: clamp(2.8rem, 5.6vw, 5.2rem);
  letter-spacing: -0.045em;
  line-height: 0.95;
  margin: 0;
}

.hero-kicker,
.mark {
  font-size: 0.78rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 1.5rem 0 0;
}

.hero-paper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: var(--paper);
  color: var(--ink);
}

.hero-paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grain);
  mix-blend-mode: multiply;
  opacity: 0.28;
  filter: invert(1);
}

.hero-construction { position: relative; width: 100%; max-width: 330px; aspect-ratio: 1; }
.hero-construction .logo-mark { position: absolute; inset: 22%; width: 56%; height: 56%; }

.hero-construction svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: var(--ink);
  stroke-width: 0.5;
}

.hero-construction .guides { opacity: 0.4; }
.hero-construction .nodes { fill: var(--ink); stroke: none; }

.hero-statement {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem var(--gutter);
}

.tagline {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.3vw, 2.2rem);
  line-height: 1.15;
  color: var(--orange);
  text-wrap: balance;
}

.hero-statement::after,
.hero-sub::after {
  content: "";
  display: block;
  width: 4rem;
  height: 2px;
  margin-top: 1.75rem;
  background: var(--orange);
}

/* Inner pages hero */
.hero-sub { padding: clamp(2rem, 5vw, 3.5rem) var(--gutter); overflow: hidden; }
.hero-sub .hero-moon { top: -60%; right: -4%; width: min(46%, 440px); opacity: 0.55; }
.hero-sub > :not(.hero-moon) { position: relative; }
.hero-sub .mark { margin: 0 0 0.75rem; }
.hero-sub h1 { font-size: clamp(2rem, 4.5vw, 3.4rem); letter-spacing: -0.035em; line-height: 1.02; margin: 0; max-width: 18ch; }
.hero-sub .tagline { font-family: var(--font-body); font-size: 1rem; line-height: 1.5; color: var(--muted); margin-top: 1rem; max-width: 46ch; }

@media (max-width: 1000px) {
  .hero-board { grid-template-columns: 1fr 1fr; }
  .hero-brand { grid-column: 1 / -1; min-height: 320px; border-bottom: 1px solid var(--line); }
  .hero-paper { border-left: 0 !important; }
  .hero-construction { max-width: 240px; }
}

@media (max-width: 480px) {
  .hero-board { grid-template-columns: 1fr; }
  .hero-paper { display: none; }
  .hero-statement { border-left: 0 !important; }
  .hero-kicker { font-size: 0.68rem; letter-spacing: 0.24em; }
  .hero-moon { opacity: 0.5; }
}

/* Bento: flush cells divided by hairlines. Empty slots show drafting paper. */
main.bento {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: 210px;
  align-content: start;
  background-image:
    linear-gradient(rgba(232, 225, 215, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 225, 215, 0.045) 1px, transparent 1px);
  background-size: 35px 35px;
}

.card {
  --accent: var(--orange);
  position: relative;
  isolation: isolate;
  grid-column: span 1;
  grid-row: span 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.2rem;
  padding: 1.25rem;
  background: var(--bg);
  /* Ring instead of borders, so neighbouring cells share one hairline. */
  box-shadow: 0 0 0 0.5px var(--line-strong);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.card.wide { grid-column: span 2; }
.card.tall { grid-row: span 2; }
.card.large { grid-column: span 2; grid-row: span 2; }

@media (max-width: 1100px) {
  main.bento { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  main.bento { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 180px; }
}

@media (max-width: 480px) {
  main.bento { grid-template-columns: 1fr; }
  .card.wide, .card.large { grid-column: span 1; }
}

/* Photos sit in the board's warm monochrome and recover their color on hover. */
.card.has-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--bg-image) center / cover no-repeat;
  filter: grayscale(1) sepia(0.22) contrast(1.06) brightness(0.8);
  transition: filter 0.5s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.card.has-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(18, 18, 18, 0.05) 20%, rgba(18, 18, 18, 0.92) 92%);
}

.card:hover::before,
.card:focus-visible::before { filter: none; transform: scale(1.04); }

.card:not(.has-bg) { transition: background 0.25s ease; }
.card:not(.has-bg):hover { background: var(--bg-raised); }

/* The per-card accent color chosen in the admin panel. */
.card-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.card:hover .card-bar,
.card:focus-visible .card-bar { transform: none; }
.card:focus-visible { outline-offset: -4px; }

.card .icon {
  display: block;
  margin-bottom: auto;
  font-size: 1.75rem;
  line-height: 1;
}

.card svg.icon { width: 2.1rem; height: 2.1rem; stroke: var(--fg); stroke-width: 1.2; }
.card .icon.icon-image { width: 2.25rem; height: 2.25rem; object-fit: contain; }
.card .icon-emoji, .card .icon-image { filter: grayscale(1) sepia(0.15); transition: filter 0.4s ease; }
.card:hover .icon, .card:focus-visible .icon { filter: none; }

.card .title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0;
  transition: color 0.2s ease;
}

.card:hover .title, .card:focus-visible .title { color: var(--orange); }
.card.large .title { font-size: clamp(1.9rem, 3vw, 2.75rem); letter-spacing: -0.035em; }
.card.tall .title, .card.wide .title { font-size: 1.6rem; }

.card .desc {
  font-size: 0.85rem;
  color: #c9c1b6;
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .desc:empty { display: none; }

.empty-state { grid-column: 1 / -1; color: var(--muted); padding: 3rem var(--gutter); }

footer.site-footer {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 1.5rem var(--gutter);
  border-top: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-access {
  position: fixed;
  bottom: 0.9rem;
  right: var(--gutter);
  z-index: 2;
  display: inline-flex;
  padding: 0.45rem;
  color: var(--muted);
  transition: color 0.2s ease;
}

.admin-access:hover { color: var(--orange); }
.admin-access svg { width: 1.1rem; height: 1.1rem; stroke-width: 1.5; }

/* Shared controls (admin and tools) */
.panel {
  background: var(--bg);
  border: 1px solid var(--line);
  padding: clamp(1.25rem, 3vw, 2rem);
}

input, select, textarea {
  min-width: 0;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 0;
  color: var(--fg);
  padding: 0.65rem 0.8rem;
  font: inherit;
  font-size: 0.9rem;
}

input::placeholder { color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 1px solid var(--orange); outline-offset: 0; border-color: var(--orange); }
input[type="color"] { padding: 0.25rem; height: 2.75rem; }

.btn,
.panel button,
.admin-shell button,
.admin-topbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  color: var(--fg);
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-size: 0.88rem;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.panel button:hover,
.admin-shell button:hover,
.admin-topbar button:hover { border-color: var(--orange); color: var(--orange); }

.btn.primary,
.panel button.primary,
.admin-shell button.primary { background: var(--orange); border-color: var(--orange); color: var(--ink); font-weight: 600; }

.btn.primary:hover,
.panel button.primary:hover,
.admin-shell button.primary:hover { background: var(--fg); border-color: var(--fg); color: var(--ink); }

.panel button:disabled { opacity: 0.5; cursor: default; }
.panel button svg { width: 1rem; height: 1rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .card:hover::before, .card:focus-visible::before { transform: none; }
}
