/* ============================================================
   CyberLicht — Global Stylesheet
   Dark-warm, typography-led, Swiss grid discipline
   ============================================================ */

/* --- Tokens: Dark theme (default) --- */
:root,
[data-theme="dark"] {
  --ink:        #1a1714;
  --ink-soft:   #2e2b27;
  --ink-muted:  #6b6560;
  --parchment:  #f4f0e8;
  --warm-white: #faf8f4;
  --gold:       #fdbd01;
  --gold-light: #fecf3e;
  --rule:       #3a3530;

  --font-serif: 'IM Fell English', Georgia, serif;
  --font-sans:  'Inter', system-ui, sans-serif;

  --measure:    68ch;
  --container:  1200px;
  --space-xs:   0.5rem;
  --space-sm:   1rem;
  --space-md:   2rem;
  --space-lg:   4rem;
  --space-xl:   8rem;
}

/* --- Tokens: Light theme --- */
[data-theme="light"] {
  --ink:        #f4f0e8;
  --ink-soft:   #e8e3d8;
  --ink-muted:  #7a7268;
  --parchment:  #1a1714;
  --warm-white: #faf8f4;
  --gold:       #c99500;
  --gold-light: #a37800;
  --rule:       #c8c0b0;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--ink);
  color: var(--parchment);
  font-family: var(--font-sans);
  font-weight: 300;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

a {
  color: inherit;
  text-decoration: none;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

h1 { font-size: clamp(2.4rem, 6vw, 4.5rem); }
h2 { font-size: clamp(1.8rem, 4vw, 3rem); }
h3 { font-size: clamp(1.2rem, 2.5vw, 1.8rem); }
h4 { font-size: 1.1rem; }

p { max-width: var(--measure); }

.serif { font-family: var(--font-serif); }
.muted { color: var(--ink-muted); }
.gold  { color: var(--gold); }

em {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--gold-light);
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--space-md);
}

.section {
  padding-block: var(--space-xl);
}

.section--alt {
  background-color: var(--ink-soft);
}

.section-label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

.section-rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin-bottom: var(--space-lg);
}

/* --- Header --- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  border-bottom: 1px solid var(--rule);
  background-color: rgba(26, 23, 20, 0.95);
  backdrop-filter: blur(8px);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

[data-theme="light"] .site-header {
  background-color: rgba(244, 240, 232, 0.95);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-serif);
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  color: var(--parchment);
  text-decoration: none;
}

.site-logo {
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.wordmark:hover .site-logo {
  opacity: 0.85;
}

/* Arrow mark: light in dark mode, dark in light mode */
[data-theme="dark"] .logo-mark {
  fill: #f4f0e8;
}

[data-theme="light"] .logo-mark {
  fill: #1a1a1a;
}

.site-nav {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.site-nav a {
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  transition: color 0.2s;
}

.site-nav a:hover {
  color: var(--parchment);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* --- Theme toggle --- */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink-muted);
  width: 34px;
  height: 34px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* Show sun in dark mode (click to go light), moon in light mode (click to go dark) */
[data-theme="dark"] .icon-moon  { display: none; }
[data-theme="dark"] .icon-sun   { display: block; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Fallback if no data-theme set yet */
.icon-moon { display: none; }
.icon-sun  { display: block; }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--parchment);
  font-size: 1.4rem;
  cursor: pointer;
}

/* --- Hero --- */
.hero {
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding-top: 64px;
  border-bottom: 1px solid var(--rule);
}

.hero__inner {
  padding-block: var(--space-xl);
}

.hero__label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-md);
}

.hero__title {
  margin-bottom: var(--space-md);
}

.hero__title em {
  display: block;
  font-size: 0.55em;
  color: var(--ink-muted);
  margin-top: 0.3em;
  font-style: italic;
}

.hero__body {
  font-size: 1.1rem;
  color: var(--ink-muted);
  max-width: 54ch;
  margin-bottom: var(--space-lg);
}

.hero__cta {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 0.8em 2em;
  transition: background 0.2s, color 0.2s;
}

.hero__cta:hover {
  background: var(--gold);
  color: var(--ink);
}

/* --- Services Grid --- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background-color: var(--rule);
  border: 1px solid var(--rule);
  margin-top: var(--space-lg);
}

@media (max-width: 900px) {
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .services-grid {
    grid-template-columns: 1fr;
  }
}

.service-item {
  background-color: var(--ink);
  padding: var(--space-md);
  transition: background 0.2s;
}

.service-item:hover {
  background-color: var(--ink-soft);
}

.service-item__number {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

.service-item__title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin-bottom: var(--space-xs);
}

.service-item__body {
  font-size: 0.85rem;
  color: var(--ink-muted);
  max-width: none;
}

/* --- Case Studies --- */
.cases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.case-card {
  border: 1px solid var(--rule);
  padding: var(--space-md);
  transition: border-color 0.2s;
}

.case-card:hover {
  border-color: var(--gold);
}

.case-card__category {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

.case-card__title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin-bottom: var(--space-xs);
}

.case-card__teaser {
  font-size: 0.88rem;
  color: var(--ink-muted);
  max-width: none;
}

.redacted {
  background-color: var(--parchment);
  color: transparent;
  border-radius: 2px;
  user-select: none;
  transition: background-color 0.2s, color 0.2s;
}

[data-theme="light"] .redacted {
  background-color: var(--parchment);
  color: transparent;
}

/* --- Zunft section --- */
.zunft-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
  margin-top: var(--space-lg);
}

.zunft-text p {
  color: var(--ink-muted);
  margin-bottom: var(--space-sm);
}

.zunft-aside {
  border: 1px solid var(--rule);
  padding: var(--space-md);
}

.zunft-aside__label {
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-sm);
}

.zunft-aside blockquote {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-style: italic;
  line-height: 1.4;
  color: var(--parchment);
}

.zunft-aside__note {
  margin-top: var(--space-md);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  max-width: none;
}

/* --- Open Source --- */
.oss-card {
  border: 1px solid var(--rule);
  padding: var(--space-md);
  margin-top: var(--space-lg);
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-md);
  align-items: start;
}

.oss-card__label {
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-xs);
}

.oss-card__title {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  margin-bottom: var(--space-sm);
}

.oss-card__body {
  color: var(--ink-muted);
  margin-bottom: var(--space-sm);
}

.oss-card__link {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid var(--gold);
  padding-bottom: 2px;
}

/* --- Community --- */
.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.community-card {
  border: 1px solid var(--rule);
  padding: var(--space-md);
}

.community-card__name {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin-bottom: var(--space-xs);
}

.community-card__body {
  font-size: 0.85rem;
  color: var(--ink-muted);
  max-width: none;
}

/* --- Contact --- */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-top: var(--space-lg);
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-field label {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.form-field input,
.form-field textarea,
.form-field select {
  background: var(--ink-soft);
  border: 1px solid var(--rule);
  color: var(--parchment);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  padding: 0.7em 1em;
  width: 100%;
  transition: border-color 0.2s;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--gold);
}

.form-field textarea {
  min-height: 160px;
  resize: vertical;
}

.form-submit {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--gold);
  background: none;
  color: var(--gold);
  padding: 0.8em 2em;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  align-self: flex-start;
}

.form-submit:hover {
  background: var(--gold);
  color: var(--ink);
}

.contact-aside p {
  color: var(--ink-muted);
  margin-bottom: var(--space-sm);
}

.contact-aside a {
  color: var(--gold);
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--rule);
  padding-block: var(--space-lg);
  margin-top: var(--space-xl);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.footer-wordmark {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin-bottom: var(--space-xs);
  max-width: none;
}

.footer-sub {
  font-size: 0.8rem;
  color: var(--ink-muted);
  line-height: 1.8;
  max-width: none;
}

.footer-label {
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-sm);
  max-width: none;
}

.footer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.footer-nav a {
  font-size: 0.85rem;
  color: var(--ink-muted);
  transition: color 0.2s;
}

.footer-nav a:hover {
  color: var(--parchment);
}

.footer-copy {
  font-size: 0.75rem;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule);
  padding-top: var(--space-sm);
  max-width: none;
}

/* --- Notes --- */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background-color: var(--rule);
  border: 1px solid var(--rule);
}

.note-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  grid-template-rows: auto auto;
  gap: 0.3rem var(--space-md);
  background-color: var(--ink);
  padding: var(--space-md);
  transition: background 0.2s;
}

.note-item:hover {
  background-color: var(--ink-soft);
}

.note-item__date {
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  grid-row: 1;
  grid-column: 1;
  padding-top: 0.3rem;
}

.note-item__category {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  grid-row: 2;
  grid-column: 1;
}

.note-item__title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 400;
  grid-row: 1;
  grid-column: 2;
}

.note-item__teaser {
  font-size: 0.85rem;
  color: var(--ink-muted);
  grid-row: 2;
  grid-column: 2;
  max-width: none;
}

/* --- Note Article --- */
.note-article {
  padding-top: calc(var(--space-xl) + 64px);
  padding-bottom: var(--space-xl);
}

.note-header {
  margin-bottom: var(--space-lg);
}

.note-header h1 {
  margin-bottom: var(--space-xs);
}

.note-date {
  font-size: 0.78rem;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  margin-bottom: var(--space-md);
  max-width: none;
}

.note-body {
  max-width: 68ch;
}

.note-body p {
  color: var(--ink-muted);
  margin-bottom: var(--space-sm);
}

.note-body h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

.note-body ul, .note-body ol {
  color: var(--ink-muted);
  padding-left: var(--space-md);
  margin-bottom: var(--space-sm);
}

.note-body li {
  margin-bottom: 0.4rem;
}

.note-body code {
  font-family: monospace;
  font-size: 0.85em;
  background: var(--ink-soft);
  padding: 0.15em 0.4em;
  border-radius: 2px;
  color: var(--gold);
}

.note-footer {
  margin-top: var(--space-xl);
  border-top: 1px solid var(--rule);
  padding-top: var(--space-md);
}

.note-back {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  transition: color 0.2s;
}

.note-back:hover {
  color: var(--gold);
}

@media (max-width: 600px) {
  .note-item {
    grid-template-columns: 1fr;
  }
  .note-item__date,
  .note-item__category,
  .note-item__title,
  .note-item__teaser {
    grid-column: 1;
  }
  .note-item__date { grid-row: 1; }
  .note-item__title { grid-row: 2; }
  .note-item__category { grid-row: 3; }
  .note-item__teaser { grid-row: 4; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
  :root {
    --space-xl: 4rem;
    --space-lg: 2.5rem;
  }

  .site-nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background-color: var(--ink);
    border-bottom: 1px solid var(--rule);
    padding: var(--space-md);
    gap: var(--space-sm);
    transition: background-color 0.25s ease;
  }

  .site-nav.open {
    display: flex;
  }

  .nav-toggle {
    display: block;
  }

  .zunft-layout,
  .contact-layout,
  .oss-card {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
}