@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Instrument+Serif&display=swap");

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-hover: #f7f7f7;
  --text: #111111;
  --text-secondary: #555555;
  --muted: #999999;
  --border: #e8e8e8;
  --border-hover: #d0d0d0;
  --accent: #111111;
  --accent-soft: #f2f2f2;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.08);
  --gutter: 2.5rem;
  --transition: 0.2s ease;
  --section-scroll-offset: 72px;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* ── Header ──────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 250, 250, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  padding: 0 var(--gutter);
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.ofs-logo {
  width: 32px;
  height: auto;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.brand-label {
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}

.brand-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.header-end {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.header-link {
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.header-link:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.header-link.is-active {
  background: var(--accent);
  color: #fff;
}

/* ── Header search ───────────────────────────────────── */

.header-search {
  position: relative;
  width: 220px;
  flex-shrink: 0;
}

.header-search .search-input-row {
  position: relative;
  display: flex;
  align-items: center;
}

.header-search .search-icon {
  position: absolute;
  left: 0.65rem;
  color: var(--muted);
  pointer-events: none;
}

.header-search input {
  width: 100%;
  height: 34px;
  padding: 0 4.5rem 0 2.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition), width var(--transition);
}

.header-search input::placeholder {
  color: #bbb;
}

.header-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
  width: 300px;
}

.header-search .search-clear {
  position: absolute;
  right: 0.3rem;
  height: 24px;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.header-search .search-clear:hover {
  background: var(--accent-soft);
}

.search-result-count {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.search-result-count:empty {
  display: none;
}

/* ── Main shell ──────────────────────────────────────── */

.portal-shell {
  padding: 2rem var(--gutter) 4rem;
}

/* ── Hero ────────────────────────────────────────────── */

.hero-section {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hero-title {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.hero-desc {
  max-width: 50ch;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* ── References ──────────────────────────────────────── */

.hero-refs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.refs-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.2rem;
}

.ref-link {
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.ref-link:hover {
  border-color: var(--border-hover);
  background: var(--accent);
  color: #fff;
}

/* ── Sections ────────────────────────────────────────── */

.sections-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portal-section {
  scroll-margin-top: var(--section-scroll-offset);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  user-select: none;
}

.portal-section:not(.is-open) .section-header {
  padding-bottom: 0;
}

.portal-section.is-open .section-header {
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.section-header-main {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.section-title {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
  transition: opacity var(--transition);
}

.section-header:hover .section-title {
  opacity: 0.6;
}

.section-count {
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  background: var(--accent-soft);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.section-desc {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}

/* ── Accordion body ──────────────────────────────────── */

.section-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}

.portal-section.is-open .section-body {
  grid-template-rows: 1fr;
}

.section-body-inner {
  overflow: hidden;
}

/* ── Subsections ─────────────────────────────────────── */

.subsections {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1.25rem;
}

.subsection {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.subsection--labeled {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-hover);
}

.subsection--paired > .paired-grid {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-hover);
}

.subsection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.subsection--labeled .subsection-header {
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--border);
}

.subsection-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.subsection-note {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
}

/* ── Cards ───────────────────────────────────────────── */

.project-grid,
.paired-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.paired-grid[data-card-count="1"],
.project-grid[data-card-count="1"] {
  grid-template-columns: minmax(280px, 480px);
}

.project-card {
  display: block;
  height: 100%;
  border-radius: var(--radius);
}

.project-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.project-card:hover .card-inner {
  transform: translateY(-1px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-hover);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-mark {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.card-category {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: right;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.card-name {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.08rem;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
}

.card-summary {
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
}

.card-meta-label {
  font-size: 0.62rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-secondary);
}

.card-arrow {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition);
}

.project-card:hover .card-arrow {
  background: var(--accent);
  color: #fff;
}

/* ── Empty state ─────────────────────────────────────── */

.empty-state {
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  margin: 2rem auto 0;
  padding: 2rem;
  text-align: center;
}

.empty-state-title {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.15rem;
  color: var(--text);
}

.empty-state-copy {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 1080px) {
  .header-nav {
    display: none;
  }
}

@media (max-width: 860px) {
  .hero-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .hero-refs {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  :root {
    --gutter: 1rem;
  }

  .brand-label {
    display: none;
  }

  .hero-title {
    font-size: clamp(1.5rem, 7vw, 2rem);
  }

  .header-search {
    width: 160px;
  }

  .header-search input:focus {
    width: 100%;
  }

  .project-grid,
  .paired-grid {
    grid-template-columns: 1fr;
  }

  .portal-section {
    padding: 1rem;
  }

  .subsections {
    padding-top: 1rem;
  }
}

@media (max-width: 480px) {
  .header-search {
    display: none;
  }

  .hero-refs {
    gap: 0.3rem;
  }

  .ref-link {
    font-size: 0.68rem;
    padding: 0.22rem 0.45rem;
  }
}

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

  .header-link,
  .card-inner,
  .card-arrow,
  .section-title,
  .ref-link,
  .header-search input {
    transition: none !important;
  }

  .section-body {
    transition: none !important;
  }
}
