/* ============================================================
   FONT IMPORTS
   @import must precede all rules per CSS spec §6.3
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@1,400&family=Inter:wght@100..900&family=Kalam:wght@400&display=swap');

/* ============================================================
   TOKENS
   ============================================================ */
:root {
  /* Color */
  --bg:        #f2ede4;
  --ink:       #2b1d0e;
  --ink-soft:  #7a6850;
  --rule:      #2b1d0e;
  --rule-soft: rgba(43, 29, 14, 0.2);

  /* Type */
  --font-sans:  "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-serif: "EB Garamond", Georgia, "Times New Roman", serif;

  /* Scale */
  --text-xs:      0.75rem;
  --text-sm:      0.875rem;
  --text-base:    1rem;
  --text-lg:      1.125rem;
  --text-xl:      1.25rem;
  --text-2xl:     clamp(1.375rem, 2.5vw, 1.875rem);
  --text-display: clamp(2.25rem, 5.5vw, 3.75rem);
  --text-intro:   clamp(1.5rem, 2.5vw, 2rem);

  /* Layout */
  --measure:   38rem;
  --gutter:    clamp(1.25rem, 4vw, 3rem);
  --shell-max: 64rem;
}

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
  border-radius: 2px;
  /* hover-off: gradual — applies to all links by default */
  transition: background-color 200ms ease, color 200ms ease;
}

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

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin-block: calc(var(--gutter) * 1.5);
}

::selection {
  background-color: var(--ink);
  color: var(--bg);
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.shell {
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.shell--narrow {
  max-width: calc(var(--measure) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell--narrow > main {
  flex: 1;
}

/* ============================================================
   MASTHEAD / NAV
   ============================================================ */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-block: var(--gutter);
  margin-bottom: calc(var(--gutter) * 2);
}

.masthead__name {
  font-family: "Kalam", cursive;
  font-weight: 400;
  font-style: normal;
  font-size: var(--text-lg);
  color: var(--ink);
  flex-shrink: 0;
  white-space: nowrap;
}

.masthead__name:hover {
  background-color: var(--ink);
  color: var(--bg);
  transition: background-color 60ms ease, color 60ms ease;
}

.masthead__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  align-items: baseline;
  justify-content: flex-end;
  list-style: none;
}

.masthead__nav a {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink);
}

.masthead__nav a:hover {
  background-color: var(--ink);
  color: var(--bg);
  transition: background-color 60ms ease, color 60ms ease;
}

/* ============================================================
   INTRO
   ============================================================ */
.intro {
  font-family: var(--font-sans);
  font-size: var(--text-intro);
  line-height: 1.35;
  max-width: var(--measure);
  margin-bottom: calc(var(--gutter) * 2.5);
  color: var(--ink);
}

.intro__name {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.intro__hover-trigger {
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: default;
}

/* ============================================================
   DIRECTORY
   ============================================================ */
.directory {
  margin-bottom: calc(var(--gutter) * 3);
}

.directory__heading {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.entry-list {
  list-style: none;
}

.entry {
  display: grid;
  grid-template-columns: 1fr auto;
  border-bottom: 1px solid var(--rule-soft);
}

.entry__link {
  display: contents;
}

.entry__main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-block: 0.875rem;
  padding-right: 1.5rem;
  min-width: 0;
  overflow: hidden;
}

.entry__title {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry__desc {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  line-height: 1.4;
}

.entry__meta {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding-block: 0.875rem;
  white-space: nowrap;
}

.entry__type {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--ink-soft);
}

.entry__year {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  min-width: 2.25rem;
  text-align: right;
}

.entry:hover .entry__title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   PROJECT PAGE
   ============================================================ */
.project-header {
  margin-bottom: calc(var(--gutter) * 2);
}

/* Tighten the masthead→title gap on desktop only, without affecting the index page */
@media (min-width: 810px) {
  .project-header {
    margin-top: calc(var(--gutter) * -0.75);
  }
}

.project-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  line-height: 1.25;
  max-width: var(--measure);
  margin-bottom: 1rem;
}

.project-dek {
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  line-height: 1.45;
  max-width: var(--measure);
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.project-date {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin-bottom: calc(var(--gutter) * 1.5);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.project-date__label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
}

.project-date svg {
  flex-shrink: 0;
  position: relative;
  top: -0.5px; /* optical alignment with text baseline */
}

.project-meta {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--rule-soft);
  border-radius: 8px;
  margin-bottom: calc(var(--gutter) * 2);
  max-width: var(--measure);
}

.project-meta__item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.project-meta__label {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
}

.project-meta__value {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink);
}

.project-meta__value a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Collaborator chip: avatar circle + linked name */
.collab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.collab__avatar {
  display: block;
  width: 14px !important;
  height: 14px !important;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  /* fallback background if image hasn't been added yet */
  background-color: var(--rule-soft);
}

.project-meta__value a:hover {
  background-color: var(--ink);
  color: var(--bg);
  text-decoration: none;
  transition: background-color 60ms ease, color 60ms ease;
}

/* ============================================================
   PROSE
   ============================================================ */
.prose {
  max-width: var(--measure);
  margin-bottom: calc(var(--gutter) * 1.5);
}

.prose > * + * {
  margin-top: 1.25rem;
}

.prose h2 {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--text-2xl);
  line-height: 1.2;
  margin-top: 2.5rem;
}

.prose__break {
  text-align: center;
  font-weight: 400;
  color: var(--ink-soft);
  letter-spacing: 0.3em;
}

.prose h3 {
  font-family: var(--font-sans);
  font-size: clamp(1.0625rem, 2.5vw, 1.25rem);
  font-weight: 700;
  margin-top: 2rem;
}

.prose p {
  font-family: var(--font-sans);
  line-height: 1.7;
}

.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(43, 29, 14, 0.5);
  /* border-radius and hover-off transition inherited from global a */
}

.prose a:hover {
  background-color: var(--ink);
  color: var(--bg);
  text-decoration: none;
  /* hover-in: snappy */
  transition: background-color 60ms ease, color 60ms ease;
}

.prose blockquote {
  font-family: var(--font-sans);
  font-size: var(--text-lg);
  line-height: 1.5;
  border-left: 2px solid var(--rule);
  padding-left: 1.5rem;
  margin-left: 0;
}

.prose code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Fira Code", monospace;
  font-size: 0.875em;
  background-color: rgba(43, 29, 14, 0.08);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}

/* ============================================================
   FIGURES
   ============================================================ */
.figure {
  max-width: var(--measure);
  margin-bottom: calc(var(--gutter) * 1.5);
}

.figure--wide {
  max-width: 100%;
  margin-bottom: calc(var(--gutter) * 1.5);
}

/* Breaks out of the measure column on wide viewports.
   Only activates above ~810px where 75vw > content width.
   Mobile: no-op — image stays full content width. */
/* Apply to the div wrapping an img to break it out of the measure column.
   Caption stays at normal text width. Mobile: no-op.
   --breakout    → 75vw (large)
   --breakout-md → 60vw (medium) */
@media (min-width: 810px) {
  .figure--breakout {
    width: 75vw;
    margin-inline: calc((100% - 75vw) / 2);
  }

  .figure--breakout img {
    width: 100%;
  }
}

/* 60vw only exceeds the measure column above ~1015px */
@media (min-width: 1015px) {
  .figure--breakout-md {
    width: 55vw;
    margin-inline: calc((100% - 55vw) / 2);
  }

  .figure--breakout-md img {
    width: 100%;
  }
}

.figure-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  max-width: var(--measure);
  margin-bottom: calc(var(--gutter) * 1.5);
}

.figure-grid figure {
  margin: 0;
}

figcaption {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  margin-top: 0.5rem;
  line-height: 1.45;
}

figcaption strong {
  color: var(--ink);
  font-weight: 600;
}

figcaption em {
  font-style: normal;
}

/* figure placeholder for template demo — remove when real images exist */
.figure__placeholder {
  background-color: rgba(43, 29, 14, 0.06);
  width: 100%;
  aspect-ratio: 16 / 9;
}

/* ============================================================
   POST NAV
   ============================================================ */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  border-top: 1px solid var(--rule);
  padding-top: calc(var(--gutter) * 1.5);
  margin-top: calc(var(--gutter) * 2);
  margin-bottom: calc(var(--gutter) * 2);
}

.post-nav__item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-width: 16rem;
  text-decoration: none;
}

.post-nav__item--next {
  align-items: flex-end;
  text-align: right;
  margin-left: auto;
}

.post-nav__label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink-soft);
}

.post-nav__title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  border-radius: 2px;
  transition: background-color 200ms ease, color 200ms ease;
}

.post-nav__item:hover .post-nav__title {
  background-color: var(--ink);
  color: var(--bg);
  text-decoration: none;
  transition: background-color 60ms ease, color 60ms ease;
}

/* ============================================================
   FOOTER
   ============================================================ */
.foot {
  border-top: 1px solid var(--rule-soft);
  padding-block: var(--gutter);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}


.foot__links {
  display: flex;
  gap: 1.25rem;
  list-style: none;
}

.foot__links a {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.foot__links a:hover {
  background-color: var(--ink);
  color: var(--bg);
  text-decoration: none;
  transition: background-color 60ms ease, color 60ms ease;
}

.foot__copy {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--ink-soft);
}

/* ============================================================
   ACCORDION ENTRY  (uses native <details>/<summary>, no JS)
   ============================================================ */

/* Override the entry grid — accordion manages its own layout */
.entry--accordion {
  display: block;
}

/* Strip all browser default summary chrome */
.entry__summary {
  list-style: none;
  display: grid;
  align-items: center;
  padding-block: 0.875rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.entry__summary::-webkit-details-marker { display: none; }

/* Inner elements carry their own padding-block in the base styles;
   zero that out here since the summary handles it */
.entry__summary .entry__main,
.entry__summary .entry__meta { padding-block: 0; }

/* Hover — underline the title (mirrors the link-entry behaviour) */
.entry__summary:hover .entry__title {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Expanded body */
.entry__body { padding-bottom: 1.5rem; }

.entry__accordion-img {
  width: 80%;
  aspect-ratio: 16 / 9;
  margin-inline: auto;
  margin-block: 1.5rem;
}

.entry__accordion-text {
  font-size: var(--text-sm);
  color: var(--ink);
  line-height: 1.7;
  max-width: var(--measure);
}

/* ----------------------------------------------------------
   Option A — Chevron hugs the title, rotates on open
   Layout: [title + chevron, 1fr] [meta auto]
   ---------------------------------------------------------- */
.entry--chevron .entry__summary {
  grid-template-columns: 1fr auto;
  gap: 0 0.75rem;
}

/* Title and chevron sit in a row inside .entry__main */
.entry--chevron .entry__summary .entry__main {
  flex-direction: row;
  align-items: center;
  gap: 0.375rem;
  padding-right: 0;
}

.entry__chevron {
  display: block;
  width: 14px;
  height: 14px;
  align-self: center;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232b1d0e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.18s ease;
}

.entry__details[open] .entry__chevron {
  transform: rotate(90deg);
}

/* ----------------------------------------------------------
   Option B — Plus / Minus at the end
   ---------------------------------------------------------- */
.entry--pm .entry__summary {
  grid-template-columns: 1fr auto 1.25rem;
  gap: 0 0.75rem;
}

.entry--pm .entry__summary::after {
  content: '';
  display: block;
  width: 13px;
  height: 13px;
  justify-self: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232b1d0e' stroke-width='1.5' stroke-linecap='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.entry--pm .entry__details[open] .entry__summary::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232b1d0e' stroke-width='1.5' stroke-linecap='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3C/svg%3E");
}

/* ============================================================
   TOAST  (index page Easter egg)
   ============================================================ */
#toast-container {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background-color: var(--ink);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: 0.45rem 0.875rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(43, 29, 14, 0.18);
  white-space: nowrap;
  animation: toast-in 0.2s ease both;
}

.toast--out {
  animation: toast-out 0.25s ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(6px); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .figure-grid {
    grid-template-columns: 1fr;
  }
}
