@import "tokens.css";

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.home {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 55% at 8% -8%, rgba(10, 92, 99, 0.09), transparent 52%),
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(196, 123, 26, 0.07), transparent 48%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  min-height: 100vh;
}

body.home::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a {
  color: var(--teal);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

img {
  max-width: 100%;
  display: block;
}

/* ── Topbar ── */
.home-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: rgba(250, 251, 252, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border: 2px solid var(--teal);
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
}

.brand-mark::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 2px var(--surface);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: 2px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}

.home-nav {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.home-nav a {
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}

.home-nav a:hover {
  background: var(--teal-soft);
  color: var(--teal-deep);
}

/* ── Hero composition ── */
.home-hero {
  max-width: 1120px;
  margin: 0 auto;
  padding: 56px 28px 48px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 40px;
  align-items: center;
  animation: home-rise 0.7s ease both;
}

.home-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 14px;
}

.home-kicker::before {
  content: "";
  width: 18px;
  height: 2px;
  background: var(--amber);
}

.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.2vw, 3rem);
  font-weight: 600;
  line-height: 1.22;
  margin: 0 0 8px;
  letter-spacing: 0.01em;
}

.home-hero .brand-line {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 700;
  color: var(--teal-deep);
  margin: 0 0 16px;
  letter-spacing: 0.02em;
}

.home-lead {
  margin: 0 0 28px;
  color: var(--ink-soft);
  font-size: 1.05rem;
  max-width: 34em;
}

.home-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--teal);
  color: #fff;
}

.btn-primary:hover {
  background: var(--teal-deep);
  color: #fff;
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink-soft);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
}

.home-hero-visual {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--frame);
  animation: home-rise 0.85s ease 0.08s both;
}

.home-hero-visual img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  opacity: 0.92;
}

.home-hero-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(10, 92, 99, 0.18), transparent 45%),
    linear-gradient(to top, rgba(20, 24, 28, 0.55), transparent 42%);
  pointer-events: none;
}

.home-hero-caption {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #dce6eb;
  letter-spacing: 0.04em;
}

/* ── Catalog section ── */
.home-section {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 28px 72px;
  animation: home-rise 0.6s ease 0.15s both;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-head .num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--amber);
  letter-spacing: 0.08em;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  margin: 0;
}

.section-desc {
  color: var(--ink-soft);
  margin: 12px 0 28px;
  max-width: 42em;
}

.wiki-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

.wiki-entry {
  grid-column: span 6;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.wiki-entry:hover {
  border-color: var(--teal);
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(20, 24, 28, 0.1);
}

.wiki-entry.featured {
  grid-column: span 12;
  grid-template-columns: 1.15fr 1fr;
  grid-template-rows: auto;
}

.wiki-entry.soon {
  opacity: 0.72;
  cursor: default;
  pointer-events: none;
}

.wiki-entry.soon:hover {
  transform: none;
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.wiki-thumb {
  position: relative;
  background: var(--frame);
  min-height: 180px;
  overflow: hidden;
}

.wiki-thumb img {
  width: 100%;
  height: 100%;
  min-height: 180px;
  object-fit: cover;
  transition: transform 0.45s ease;
}

.wiki-entry:hover .wiki-thumb img {
  transform: scale(1.03);
}

.wiki-entry.featured .wiki-thumb {
  min-height: 280px;
}

.wiki-thumb .status {
  position: absolute;
  top: 12px;
  left: 12px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 2px;
  background: var(--teal);
  color: #fff;
  z-index: 1;
}

.wiki-thumb .status.soon {
  background: var(--frame);
  color: #c5d0db;
  border: 1px solid #3a4450;
}

.wiki-body {
  padding: 20px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wiki-meta {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.wiki-body h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

.wiki-body p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
  flex: 1;
}

.wiki-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.wiki-tags span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 3px 8px;
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  color: var(--ink-soft);
}

.wiki-go {
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--teal);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wiki-entry:hover .wiki-go {
  color: var(--teal-deep);
}

.wiki-go::after {
  content: "→";
  transition: transform 0.15s;
}

.wiki-entry:hover .wiki-go::after {
  transform: translateX(3px);
}

/* ── External links (collapsible) ── */
.home-links-section {
  padding-top: 0;
}

.home-links-summary {
  list-style: none;
  align-items: center;
  width: 100%;
  cursor: pointer;
  user-select: none;
}

.home-links-summary::-webkit-details-marker,
.home-links-summary::marker {
  display: none;
  content: "";
}

.home-links-chevron {
  width: 10px;
  height: 10px;
  margin-left: auto;
  margin-right: 2px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease, border-color 0.15s;
  flex-shrink: 0;
}

.home-links-summary:hover .home-links-chevron {
  border-color: var(--teal);
}

.home-links-fold[open] .home-links-chevron {
  transform: rotate(225deg);
  margin-top: 4px;
  border-color: var(--teal);
}

.home-links-panel {
  padding: 16px 0 8px;
}

.home-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.home-link-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}

.home-link-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--teal);
}

.home-link-card:hover {
  border-color: var(--teal);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(20, 24, 28, 0.07);
}

.home-link-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--teal);
  flex-shrink: 0;
}

.home-link-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.home-link-name {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
}

.home-link-desc {
  font-size: 0.86rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

.home-link-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.home-link-url {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--teal);
}

.home-link-arrow {
  color: var(--muted);
  font-size: 0.9rem;
  transition: transform 0.18s, color 0.18s;
}

.home-link-card:hover .home-link-arrow {
  transform: translate(2px, -2px);
  color: var(--teal);
}

/* ── Principles strip ── */
.principle-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 8px;
}

.principle {
  padding: 18px 18px 20px;
  border-left: 3px solid var(--teal);
  background: var(--teal-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.principle:nth-child(2) {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.principle:nth-child(3) {
  border-left-color: var(--frame);
  background: var(--paper);
}

.principle strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 6px;
}

.principle p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* ── Footer ── */
.home-footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 28px 48px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: space-between;
}

.home-footer a {
  color: var(--muted);
  text-decoration: none;
}

.home-footer a:hover {
  color: var(--teal);
}

@keyframes home-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .home-hero {
    grid-template-columns: 1fr;
    padding: 28px 22px 32px;
    gap: 22px;
  }

  .home-hero .brand-line {
    font-size: clamp(1.9rem, 8vw, 2.6rem);
    margin-bottom: 10px;
  }

  .home-hero h1 {
    font-size: clamp(1.35rem, 5.5vw, 1.75rem);
  }

  .home-lead {
    font-size: 0.95rem;
    margin-bottom: 20px;
  }

  .wiki-entry,
  .wiki-entry.featured {
    grid-column: span 12;
    grid-template-columns: 1fr;
  }

  .wiki-entry.featured .wiki-thumb {
    min-height: 180px;
  }

  .principle-row {
    grid-template-columns: 1fr;
  }

  .brand-sub {
    display: none;
  }

  .home-section {
    padding: 4px 22px 48px;
  }
}

@media (max-width: 560px) {
  .home-topbar {
    padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    height: calc(52px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  .home-hero,
  .home-section,
  .home-footer {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .home-footer {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }

  .home-nav a:not(:last-child) {
    display: none;
  }

  .home-nav a:last-child {
    font-size: 0.78rem;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
  }

  .home-cta {
    flex-direction: column;
    align-items: stretch;
  }

  .home-cta .btn {
    justify-content: center;
    width: 100%;
  }

  .home-hero-visual img {
    aspect-ratio: 16 / 11;
  }

  .home-hero-caption {
    font-size: 0.65rem;
    left: 12px;
    right: 12px;
    bottom: 10px;
  }

  .wiki-body {
    padding: 16px 16px 18px;
  }

  .wiki-body h3 {
    font-size: 1.2rem;
  }

  .section-head h2 {
    font-size: 1.35rem;
  }

  .home-link-card {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
  }

  .home-link-meta {
    grid-column: 2;
    justify-self: start;
  }

  .home-link-arrow {
    display: none;
  }
}
