/* ==========================================================================
   Kingside AS — kingside.no
   Statisk énside. Ingen avhengigheter, ingen JS, ingen sporing.
   Palett: varm elfenben + blekk + messing-gull (arv fra Sjakkrating og TGN).
   ========================================================================== */

/* ---- Tokens ---- */
:root {
  --paper: #faf7f2;
  --surface: #ffffff;
  --ink: #211d19;
  --ink-soft: #5c544a;
  --line: #e7dfd2;

  --gold: #c9a26b;          /* dekor, store flater */
  --gold-strong: #7a5c37;   /* tekst-trygg på lys bakgrunn */
  --gold-bright: #e4c89e;   /* TGN-gull, på mørke flater */

  --hero-ink: #1d1a16;
  --hero-ink-2: #2b2419;
  --hero-text: #f4eee3;
  --hero-muted: #bfb39c;

  --board-light: #f0d9b5;   /* klassiske brettfarger (Sjakkrating) */
  --board-dark: #b58863;

  --teal: #0d9488;          /* Sjakkrating-aksent */
  --teal-hi: #14b8a6;
  --teal-deep: #0f766e;
  --teal-bright: #2dd4bf;   /* tekst-trygg på mørk bakgrunn */
  --rust: #924421;          /* TGN-aksent */
  --charcoal: #272727;

  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --sq: clamp(54px, 9vw, 76px);
  --radius: 14px;
  --measure: 62ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #232019;
    --surface: #2b2721;
    --ink: #ece5d8;
    --ink-soft: #b5aa97;
    --line: #3a352c;
    --gold-strong: #d9b988;
  }
}

/* ---- Base ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.01em;
}

a { color: var(--gold-strong); }

:focus-visible {
  outline: 2px solid var(--gold-strong);
  outline-offset: 3px;
  border-radius: 2px;
}

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

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--gold-strong);
  margin-bottom: 1rem;
}

/* ==========================================================================
   Toppfelt: header + hero (delt mørk flate med brett-tekstur)
   ========================================================================== */
.top {
  position: relative;
  background: linear-gradient(160deg, var(--hero-ink) 55%, var(--hero-ink-2));
  color: var(--hero-text);
  overflow: hidden;
}

/* Subtil sjakkbrett-tekstur — samme grep som sjakkrating.no sin hero */
.top::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Crect width='24' height='24' fill='%23ffffff'/%3E%3Crect x='24' y='24' width='24' height='24' fill='%23ffffff'/%3E%3C/svg%3E");
  opacity: 0.015;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(200deg, black, transparent 75%);
  mask-image: linear-gradient(200deg, black, transparent 75%);
}

.top > * { position: relative; }

.top .eyebrow { color: var(--gold-bright); }

/* ---- Header ---- */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.6rem 24px 0;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--hero-text);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.wordmark-as {
  font-size: 0.85em;
  color: var(--gold-bright);
}

.header-mail {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--hero-muted);
  text-decoration: none;
}
.header-mail:hover { color: var(--gold-bright); }

/* ---- Hero ---- */
.hero { padding: clamp(3.5rem, 9vh, 6.5rem) 24px clamp(4rem, 10vh, 7rem); }

.hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  align-items: center;
  gap: clamp(2.5rem, 6vw, 5rem);
}

.hero h1 {
  font-size: clamp(2.1rem, 4.6vw, 3.3rem);
  max-width: 16ch;
  margin-bottom: 1.1rem;
}

.lead {
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  color: var(--hero-muted);
  max-width: 46ch;
  margin-bottom: 2rem;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  flex-wrap: wrap;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border: 1px solid var(--gold-bright);
  border-radius: 10px;
  color: var(--gold-bright);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}
.btn:hover {
  background: var(--gold-bright);
  color: var(--hero-ink);
}

.link-quiet {
  color: var(--hero-muted);
  font-size: 0.95rem;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.link-quiet:hover {
  color: var(--hero-text);
  border-bottom-color: var(--hero-muted);
}

/* ---- Rokade-diagrammet (signaturen) ----
   Utsnitt av første rad, e1–h1. Kongen glir e1→g1, så tårnet h1→f1.
   Uten animasjon (prefers-reduced-motion) vises sluttstillingen. */
.castling { justify-self: center; }

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, var(--sq));
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.sq { width: var(--sq); height: var(--sq); }
.sq-light { background: var(--board-light); }
.sq-dark  { background: var(--board-dark); }

.piece {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--sq);
  height: var(--sq);
  display: grid;
  place-items: center;
  font-size: calc(var(--sq) * 0.68);
  line-height: 1;
  color: #241f1a;
  user-select: none;
}

/* Sluttstilling som standard (gjelder også ved redusert bevegelse) */
.king { transform: translateX(calc(var(--sq) * 2)); }              /* e1 → g1 */
.rook { left: calc(var(--sq) * 3); transform: translateX(calc(var(--sq) * -2)); } /* h1 → f1 */

.files {
  display: grid;
  grid-template-columns: repeat(4, var(--sq));
  margin-top: 0.45rem;
}
.files span {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--hero-muted);
}

.notation {
  margin-top: 1rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  color: var(--gold-bright);
}

@media (prefers-reduced-motion: no-preference) {
  .king { animation: castle-king 0.65s 1.05s cubic-bezier(0.4, 0, 0.2, 1) both; }
  .rook { animation: castle-rook 0.65s 1.9s cubic-bezier(0.4, 0, 0.2, 1) both; }
  .notation { animation: fade-in 0.8s 2.75s ease both; }

  @keyframes castle-king {
    from { transform: translateX(0); }
    to   { transform: translateX(calc(var(--sq) * 2)); }
  }
  @keyframes castle-rook {
    from { transform: translateX(0); }
    to   { transform: translateX(calc(var(--sq) * -2)); }
  }
  @keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

/* ==========================================================================
   Seksjoner
   ========================================================================== */
.section { padding: clamp(4rem, 9vh, 6.5rem) 24px; }

.section-inner {
  max-width: 1100px;
  margin: 0 auto;
}
.section-inner.narrow { max-width: 720px; }
.section-inner.center { text-align: center; }

.section h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-bottom: 1.2rem;
}

.section p + p { margin-top: 1rem; }

.about p:not(.eyebrow), .contact p:not(.eyebrow) { max-width: var(--measure); color: var(--ink-soft); }
.about p:not(.eyebrow) { color: var(--ink); }
.about p:last-of-type { color: var(--ink-soft); }
.contact .section-inner.center p { margin-inline: auto; }

.products { border-top: 1px solid var(--line); }
.people   { border-top: 1px solid var(--line); }
.contact  { border-top: 1px solid var(--line); }

/* ---- Produktkort — hvert barn beholder sin egen merkevare-aksent ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.5rem;
  margin-top: 2.2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.8rem;
  box-shadow: 0 1px 3px rgba(33, 29, 25, 0.05);
}

.card-sjakkrating { border-top: 3px solid var(--teal); }
.card-tgn         { border-top: 3px solid var(--gold); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1.3rem;
}

.tile {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.tile .knight {
  font-size: 34px;
  line-height: 1;
}

/* Sjakkrating: hvit springer på teal-flis — som deres faktiske favicon */
.tile-sjakkrating {
  border-radius: 13px;
  background: linear-gradient(135deg, var(--teal-hi), var(--teal-deep));
}
.tile-sjakkrating .knight { color: #ffffff; }

/* TGN: todelt gull/rust-springer på koksgrå sirkel — som app-ikonet */
.tile-tgn {
  border-radius: 50%;
  background: var(--charcoal);
}
.tile-tgn .knight {
  background: linear-gradient(90deg, var(--gold-bright) 50%, var(--rust) 50%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.pill {
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.3rem 0.65rem;
  border-radius: 99px;
  border: 1px solid;
  text-align: center;
}
.pill-live { color: var(--teal-deep); border-color: var(--teal); }
.pill-soon { color: var(--gold-strong); border-color: var(--gold); }

@media (prefers-color-scheme: dark) {
  .pill-live { color: var(--teal-bright); border-color: var(--teal-bright); }
  .pill-soon { color: var(--gold-bright); border-color: var(--gold-bright); }
  .tile-tgn  { border: 1px solid var(--line); }
}

.card h3 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.card p {
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-bottom: 1.2rem;
}

.card-link {
  font-family: var(--mono);
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--gold-strong);
}
.card-link:hover { text-decoration: underline; }
.card-link-muted { color: var(--ink-soft); }

/* ---- Folkene bak — to grunnleggere, to brikker (kongen og tårnet) ----
   Kortene utvides ved klikk med native <details> — ingen JS. */
.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
  align-items: start;
}

/* Når alle kortene er åpne: strekk til lik høyde */
.people-grid:has(details[open]):not(:has(details:not([open]))) {
  align-items: stretch;
}

.person {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(33, 29, 25, 0.05);
}

.person-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 1rem;
  align-items: center;
  padding: 1.4rem 1.6rem;
  cursor: pointer;
  list-style: none;
}
.person-summary::-webkit-details-marker { display: none; }

.person-piece {
  font-size: 2.1rem;
  line-height: 1;
  color: var(--gold-strong);
}

.person-id { display: grid; row-gap: 0.1rem; }

.person-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.1rem;
}

.person-role {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.person-toggle {
  font-family: var(--mono);
  font-size: 1.15rem;
  line-height: 1;
  color: var(--gold-strong);
  transition: transform 200ms ease;
}
.person-toggle::before { content: "+"; }
details[open] .person-toggle { transform: rotate(45deg); }

.person-summary:hover .person-toggle { color: var(--ink); }

.person-bio {
  margin: 0 1.6rem 1.4rem;
  padding-top: 0.95rem;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  color: var(--ink-soft);
}

@media (prefers-reduced-motion: no-preference) {
  details[open] .person-bio { animation: bio-in 220ms ease; }

  @keyframes bio-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: none; }
  }
}

/* ---- Kontakt ---- */
.contact-mail {
  display: inline-block;
  margin-top: 1.6rem;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  font-weight: 600;
  color: var(--gold-strong);
  text-decoration: none;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 0.15rem;
}
.contact-mail:hover { border-bottom-color: var(--gold-strong); }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background: var(--hero-ink);
  color: var(--hero-muted);
  padding: 3.5rem 24px 2rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.footer-wordmark {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--gold-bright);
}

.footer-tagline {
  font-size: 0.9rem;
  margin-top: 0.3rem;
}

.footer-facts {
  font-style: normal;
  font-size: 0.9rem;
  text-align: right;
}

.footer-facts a { color: var(--gold-bright); text-decoration: none; }
.footer-facts a:hover { text-decoration: underline; }

.footer-legal {
  max-width: 1100px;
  margin: 2.5rem auto 0;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(228, 200, 158, 0.15);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  opacity: 0.75;
}

/* ==========================================================================
   Responsivt
   ========================================================================== */
@media (max-width: 820px) {
  .hero-inner {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .castling {
    justify-self: center;
    margin-top: 0.5rem;
  }

  .footer-inner { flex-direction: column; }
  .footer-facts { text-align: left; }
}
