/* ============================================================
   Chayan Rellan, github.io
   Warm manuscript aesthetic: cream paper, slate ink, gold leaf.
   ============================================================ */

:root {
  --background:       42 45% 97%;
  --foreground:       215 28% 17%;
  --card:             40 40% 95%;
  --muted:            40 25% 88%;
  --muted-foreground: 215 15% 45%;
  --border:           40 20% 82%;
  --gold:             43 65% 48%;
  --bronze:           30 40% 38%;
  --dusty-rose:       350 30% 55%;
  --burnt-sienna:     15 50% 40%;
  --slate:            215 28% 40%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --background:       215 35% 12%;
    --foreground:       42 45% 95%;
    --card:             215 30% 15%;
    --muted:            215 20% 25%;
    --muted-foreground: 42 20% 65%;
    --border:           215 20% 25%;
    --gold:             43 74% 52%;
    --bronze:           30 45% 45%;
    --dusty-rose:       350 35% 65%;
    --burnt-sienna:     15 60% 45%;
    --slate:            215 25% 60%;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

.font-display,
h1, h2, h3, h4 {
  font-family: "Cormorant Garamond", "EB Garamond", Georgia, serif;
}

/* Layout ------------------------------------------------------------------ */
main {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 24px 72px;
}

/* Top nav (tab bar) -------------------------------------------------------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: hsl(var(--background) / 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid hsl(var(--border));
}
.topnav-inner {
  max-width: 62rem;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: hsl(var(--foreground));
  text-decoration: none;
}
.brand:hover { color: hsl(var(--gold)); }
.topnav-links {
  display: flex;
  gap: 22px;
}
.topnav-links a {
  font-size: 0.95rem;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  padding-bottom: 2px;
  background: linear-gradient(to right, hsl(var(--gold)), hsl(var(--gold))) no-repeat;
  background-size: 0% 2px;
  background-position: left bottom;
  transition: color 0.2s, background-size 0.3s ease;
}
.topnav-links a:hover { color: hsl(var(--gold)); }
.topnav-links a.active {
  color: hsl(var(--foreground));
  font-weight: 600;
  background-size: 100% 2px;
}

/* Tab panels ---------------------------------------------------------------- */
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: tab-in 0.35s ease;
}
@keyframes tab-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.tab-panel > .section:first-child { padding-top: 44px; }
#panel-home > .hero { padding-top: 40px; }

/* Links ------------------------------------------------------------------- */
a { color: hsl(var(--foreground)); }
.illuminated-link {
  position: relative;
  text-decoration: none;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: linear-gradient(to right, hsl(var(--gold)), hsl(var(--gold))) no-repeat;
  background-size: 0% 2px;
  background-position: left bottom;
  transition: background-size 0.3s ease, color 0.2s ease;
  padding-bottom: 1px;
}
.illuminated-link:hover {
  background-size: 100% 2px;
  color: hsl(var(--gold));
}

/* HERO -------------------------------------------------------------------- */
.hero {
  padding: 48px 0 20px;
  text-align: center;
}
.photo-ornament {
  position: relative;
  width: 208px;
  height: 208px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
}
.photo-ornament svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.whirl-slow   { animation: whirl 60s linear infinite; transform-origin: center; }
.whirl-medium { animation: whirl 38s linear infinite reverse; transform-origin: center; }
.whirl-fast   { animation: whirl 24s linear infinite; transform-origin: center; }
@keyframes whirl {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.hero-photo {
  width: 176px;
  height: 176px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 4px 20px -4px hsl(var(--bronze) / 0.35),
    0 2px 8px -2px hsl(var(--gold) / 0.2);
}
.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero h1 {
  margin: 0 0 4px;
  font-size: clamp(2.6rem, 6vw, 3.6rem);
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.1;
}
.hero-tagline {
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-style: italic;
  color: hsl(var(--muted-foreground));
}
.hero-role {
  margin: 0 0 22px;
  font-size: 0.98rem;
  color: hsl(var(--muted-foreground));
}
.hero-role strong {
  color: hsl(var(--foreground));
  font-weight: 500;
}
.hero-links {
  display: flex;
  justify-content: center;
  gap: 26px;
  flex-wrap: wrap;
  font-size: 1.02rem;
}

/* Ornamental divider ------------------------------------------------------- */
.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 56px auto;
  color: hsl(var(--gold));
  font-size: 0.9rem;
}
.divider .line {
  height: 1px;
  width: 72px;
}
.divider .line.left  { background: linear-gradient(to right, transparent, hsl(var(--gold))); }
.divider .line.right { background: linear-gradient(to left,  transparent, hsl(var(--gold))); }

/* Split sections (heading left, content right) ----------------------------- */
.section { scroll-margin-top: 24px; }
.section-gap { margin-top: 56px; }
.featured-title {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0.2rem 0 10px;
}
.split {
  display: flex;
  gap: 32px;
}
.split-head { width: 21%; flex-shrink: 0; }
.split-head h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 600;
  position: sticky;
  top: 24px;
}
.split-body {
  flex: 1;
  min-width: 0;
  max-width: 44rem;
}
.split-body > p:first-child { margin-top: 0.3rem; }
.lede {
  font-size: 1.1rem;
  margin: 0.3rem 0 1.2rem;
}
.muted { color: hsl(var(--muted-foreground)); }

/* Work entries ------------------------------------------------------------- */
.work-list {
  display: flex;
  flex-direction: column;
}
.work-entry {
  padding: 26px 0;
  border-bottom: 1px solid hsl(var(--border));
}
.work-entry:first-child { padding-top: 6px; }
.work-entry:last-child { border-bottom: none; }
.entry-org {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: hsl(var(--bronze));
  font-family: "EB Garamond", serif;
  font-weight: 500;
}
.work-entry h3 {
  margin: 4px 0 10px;
  font-size: 1.45rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.work-entry p {
  margin: 0 0 10px;
  font-size: 1.02rem;
}
.runin {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  margin-right: 8px;
  font-family: "EB Garamond", serif;
}
.runin.problem { color: hsl(var(--burnt-sienna)); }
.runin.built   { color: hsl(var(--slate)); }
.runin.impact  { color: hsl(var(--gold)); }
.entry-meta {
  margin: 4px 0 0;
  font-style: italic;
  font-size: 0.95rem;
  color: hsl(var(--muted-foreground));
}

/* Buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 22px;
  border-radius: 2rem;
  font-family: "EB Garamond", serif;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1.5px solid hsl(var(--bronze) / 0.35);
  background: transparent;
  color: hsl(var(--foreground));
  transition: border-color 0.2s, color 0.2s, box-shadow 0.2s, background 0.2s;
}
.btn:hover {
  border-color: hsl(var(--gold));
  color: hsl(var(--gold));
  box-shadow: 0 2px 12px hsl(var(--gold) / 0.15);
}
.btn.primary {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  border-color: hsl(var(--foreground));
}
.btn.primary:hover {
  background: hsl(var(--gold));
  border-color: hsl(var(--gold));
  color: hsl(215 35% 12%);
  box-shadow: 0 4px 18px hsl(var(--gold) / 0.3);
}

/* Featured project ---------------------------------------------------------- */
.repo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  margin: 14px 0 8px;
  font-size: 1.02rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 34px;
}
.feature {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.75rem;
  padding: 22px 24px;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.feature:hover {
  transform: translateY(-2px);
  border-color: hsl(var(--gold) / 0.5);
  box-shadow:
    0 4px 20px -4px hsl(var(--bronze) / 0.2),
    0 2px 8px -2px hsl(var(--gold) / 0.1);
}
.feature h3 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 600;
}
.feature h3::before {
  content: "✦ ";
  color: hsl(var(--gold));
  font-size: 0.85em;
}
.feature p {
  margin: 0;
  font-size: 0.98rem;
  color: hsl(var(--muted-foreground));
}

/* Pipeline ----------------------------------------------------------------- */
.pipeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 34px 0 12px;
}
.pipeline-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}
.agent-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.6rem;
  padding: 16px 18px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.agent-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px -4px hsl(var(--bronze) / 0.25);
}
.agent-card h4 {
  margin: 0 0 4px;
  font-size: 1.12rem;
  font-weight: 600;
}
.agent-card p {
  margin: 0;
  font-size: 0.92rem;
  color: hsl(var(--muted-foreground));
}
.agent-card.scout     { border-left: 3px solid hsl(var(--slate)); }
.agent-card.macro     { border-left: 3px solid hsl(var(--gold)); }
.agent-card.analyst   { border-left: 3px solid hsl(var(--dusty-rose)); }
.agent-card.risk      { border-left: 3px solid hsl(var(--burnt-sienna)); }
.agent-card.validator { border-left: 3px solid hsl(var(--bronze)); }
.agent-card.executor  { border-left: 3px solid hsl(var(--gold)); }
.agent-card.reporter  { border-left: 3px solid hsl(var(--slate)); }
.agent-card.historian { border-left: 3px solid hsl(var(--bronze)); }
.arrow-step {
  align-self: center;
  font-size: 1.3rem;
  color: hsl(var(--gold));
}
.footnote {
  color: hsl(var(--muted-foreground));
  font-size: 0.95rem;
  margin-top: 16px;
}

/* Constitution rules -------------------------------------------------------- */
.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 34px;
}
.rule {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.6rem;
  padding: 20px 22px 18px;
  transition: transform 0.2s, border-color 0.2s;
}
.rule:hover {
  transform: translateY(-2px);
  border-color: hsl(var(--gold) / 0.5);
}
.rule-label {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.rule-value {
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
  font-weight: 600;
  color: hsl(var(--gold));
  line-height: 1.2;
}
.rule-value .unit { font-size: 1.2rem; }
.rule-value.small {
  font-size: 1.02rem;
  font-family: "EB Garamond", serif;
  font-weight: 500;
  color: hsl(var(--foreground));
  line-height: 1.5;
}
.rule-note {
  color: hsl(var(--muted-foreground));
  font-size: 0.9rem;
  margin-top: 4px;
}
.rule.denied { border-color: hsl(var(--burnt-sienna) / 0.5); }
.rule.denied .rule-label { color: hsl(var(--burnt-sienna)); }

/* Skills -------------------------------------------------------------------- */
.skill-list {
  display: flex;
  flex-direction: column;
}
.skill-row {
  padding: 16px 0;
  border-bottom: 1px solid hsl(var(--border));
}
.skill-row:first-child { padding-top: 6px; }
.skill-row:last-child { border-bottom: none; }
.skill-row h4 {
  margin: 0 0 2px;
  font-size: 1.18rem;
  font-weight: 600;
}
.skill-row p {
  margin: 0;
  font-size: 0.98rem;
  color: hsl(var(--muted-foreground));
}

/* Background ---------------------------------------------------------------- */
.bg-list {
  display: flex;
  flex-direction: column;
}
.bg-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid hsl(var(--border));
}
.bg-row:first-child { padding-top: 6px; }
.bg-row:last-child { border-bottom: none; }
.bg-row h4 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}
.bg-row p {
  margin: 0;
  font-size: 0.95rem;
  color: hsl(var(--muted-foreground));
}
.bg-when {
  flex-shrink: 0;
  font-size: 0.92rem;
  color: hsl(var(--muted-foreground));
  font-style: italic;
}

/* Contact form --------------------------------------------------------------- */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 8px 0 30px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field span {
  font-size: 0.88rem;
  color: hsl(var(--muted-foreground));
}
.field input,
.field textarea {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  padding: 10px 14px;
  color: hsl(var(--foreground));
  font-family: "EB Garamond", serif;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: hsl(var(--gold));
  box-shadow: 0 0 0 3px hsl(var(--gold) / 0.15);
}
.hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.form-status { margin: 0; font-size: 0.95rem; color: hsl(var(--muted-foreground)); }
.form-status.ok  { color: hsl(var(--gold)); }
.form-status.err { color: hsl(var(--burnt-sienna)); }

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 28px;
  font-size: 1.02rem;
}

/* Inline code ---------------------------------------------------------------- */
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82em;
  background: hsl(var(--muted) / 0.6);
  border: 1px solid hsl(var(--border));
  padding: 1px 6px;
  border-radius: 5px;
  color: hsl(var(--bronze));
}

/* Footer --------------------------------------------------------------------- */
.footer {
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
  font-size: 0.92rem;
  text-align: center;
}
.footer .fleuron { color: hsl(var(--gold)); }

/* Reveal animations ----------------------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal-in {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive ------------------------------------------------------------------ */
@media (max-width: 760px) {
  .topnav { padding-top: 18px; }
  .topnav-links { gap: 14px; flex-wrap: wrap; }
  .split { flex-direction: column; gap: 8px; }
  .split-head { width: auto; }
  .split-head h2 { position: static; }
  .field-row { grid-template-columns: 1fr; }
  .pipeline-row { grid-template-columns: 1fr; }
  .arrow-step {
    transform: rotate(90deg);
    justify-self: center;
    margin: -6px 0;
  }
  .hero { padding-top: 28px; }
  .photo-ornament { width: 176px; height: 176px; }
  .hero-photo { width: 148px; height: 148px; }
  .divider { margin: 40px auto; }
  .bg-row { flex-direction: column; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .whirl-slow, .whirl-medium, .whirl-fast { animation: none; }
  .reveal { transition: none; opacity: 1; transform: none; }
  .tab-panel.active { animation: none; }
}
