/* =========================================================================
   COMPONENTS — buttons, tags, panels, cards, device mockups, lightbox.
   ========================================================================= */

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--fg);
  --btn-bd: var(--line-strong);
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0.78rem 1.35rem;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              color var(--dur-2) var(--ease);
}

.btn--primary {
  --btn-bg: var(--ink);
  --btn-fg: var(--on-ink);
  --btn-bd: var(--ink);
}
.btn--primary:hover { --btn-bg: var(--ink-hover); --btn-bd: var(--ink-hover); }

.btn--ghost:hover { --btn-bg: rgba(32, 26, 16, 0.05); --btn-bd: var(--fg-mid); }

.btn--sm { padding: 0.5rem 0.9rem; font-size: var(--t-xs); }

/* Text link: underlined on hover, nothing more. */
.link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
  text-underline-offset: 0.25em;
}
.link:hover { text-decoration: underline; }

/* ---- Tags & status ----------------------------------------------------- */
.tags { display: flex; flex-wrap: wrap; gap: var(--s-2); }

.tag {
  display: inline-block;
  padding: 0.22rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--fg-mid);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  color: var(--fg-mid);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--t-xs);
  white-space: nowrap;
}

/* ---- Filter bar -------------------------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-6);
}
.filter {
  padding: 0.45rem 0.95rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--fg-mid);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--t-sm);
  cursor: pointer;
  transition: color var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              background var(--dur-2) var(--ease);
}
.filter:hover { color: var(--fg); border-color: var(--line-strong); }
.filter[aria-pressed='true'] {
  color: var(--on-ink);
  background: var(--ink);
  border-color: var(--ink);
}
.filter__count { opacity: 0.55; margin-left: 0.35rem; }

/* ---- Panel ------------------------------------------------------------- */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

/* ---- Project card ------------------------------------------------------ */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color var(--dur-2) var(--ease);
}
.card:hover,
.card:focus-within { border-color: var(--fg-dim); }

.card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-3);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.card__media img { width: 100%; height: 100%; object-fit: cover; }

.card__body {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-5);
  flex: 1;
}
.card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.card__cat { color: var(--fg-dim); }
.card__title { font-size: 1.18rem; }
.card__title a { text-decoration: none; }
/* The whole card is the hit area; the anchor keeps the semantics. */
.card__title a::before { content: ''; position: absolute; inset: 0; z-index: 1; }
.card__desc { color: var(--fg-mid); font-size: var(--t-sm); flex: 1; }
.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding-top: var(--s-1);
}
.card__links { position: relative; z-index: 2; display: flex; gap: var(--s-4); }
.card__links a {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--t-xs);
  color: var(--fg-mid);
  text-decoration: none;
}
.card__links a:hover { color: var(--fg); }

/* ---- Placeholder media ------------------------------------------------- */
.media-empty {
  display: grid;
  place-content: center;
  gap: var(--s-2);
  height: 100%;
  padding: var(--s-4);
  text-align: center;
  background: var(--surface-3);
  color: var(--fg-dim);
}
.media-empty__icon { font-family: var(--font-mono); font-size: 1.35rem; opacity: 0.5; }
.media-empty__text {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--t-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* A slot the owner fills in. Deliberately reads as an instruction, not work. */
.slot {
  display: grid;
  place-content: center;
  gap: var(--s-2);
  min-height: 240px;
  padding: var(--s-6);
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: rgba(32, 26, 16, 0.018);
  color: var(--fg-dim);
}
.slot strong { color: var(--fg-mid); font-weight: 600; }
.slot code { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--fg-mid); }

/* ---- Window (macOS-style frame) ---------------------------------------
   A light-mode app window: title bar, the three traffic lights, a new-tab
   "+". The lights are the only saturated colour on the page; they are what
   makes the frame read as a Mac at a glance. */
.window {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-1);
}
.window__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 16px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--line);
}
.window__lights { display: flex; gap: 8px; }
.window__lights i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.18);
}
.window__lights i:nth-child(1) { background: #ff5f57; }
.window__lights i:nth-child(2) { background: #febc2e; }
.window__lights i:nth-child(3) { background: #28c840; }
.window__plus {
  font-size: 1.15rem;
  font-weight: 300;
  line-height: 1;
  color: var(--fg-dim);
}
.window__body {
  position: relative;
  padding: clamp(1.5rem, 3.6vw, 3.25rem) clamp(1.25rem, 5vw, 4.5rem);
}

/* ---- Browser mockup ---------------------------------------------------- */
.browser {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-1);
}
.browser__bar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0.6rem 0.8rem;
  background: var(--surface-3);
  border-bottom: 1px solid var(--line);
}
.browser__dots { display: flex; gap: 6px; flex: none; }
.browser__dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-4); }
.browser__url {
  flex: 1;
  min-width: 0;
  padding: 0.22rem 0.7rem;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  color: var(--fg-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.browser__screen {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--surface-3);
  overflow: hidden;
}
.browser__screen img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }

/* ---- Fact table -------------------------------------------------------- */
.facts { display: grid; gap: 0; border-top: 1px solid var(--line); }
.facts > div {
  display: grid;
  grid-template-columns: minmax(88px, 8rem) 1fr;
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-sm);
}
.facts dt {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--t-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-dim);
  padding-top: 0.15rem;
}
.facts dd { margin: 0; color: var(--fg); }
@media (max-width: 480px) {
  .facts > div { grid-template-columns: 1fr; gap: var(--s-1); }
}

/* ---- Gallery ----------------------------------------------------------- */
/* An even grid: every render gets the same room, and the caption sits under
   the image rather than appearing over it on hover. */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr));
  gap: var(--s-6) var(--s-5);
}
.gallery__item { margin: 0; }
.gallery__open {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-3);
  cursor: zoom-in;
  aspect-ratio: 16 / 9;
}
.gallery__open img { width: 100%; height: 100%; object-fit: cover; }
.gallery__cap { margin-top: var(--s-3); font-size: var(--t-sm); }
.gallery__cap strong { font-weight: 600; }
.gallery__cap span { display: block; color: var(--fg-dim); }
.gallery__source { margin: var(--s-6) 0 0; font-size: var(--t-sm); }

/* ---- Breakdown: 3D previews beside the final render -------------------- */
.breakdown {
  margin-top: var(--s-8);
  padding-top: var(--s-7);
  border-top: 1px solid var(--line);
}
.breakdown__head { margin-bottom: var(--s-5); }
.breakdown__head h3 { margin: 0; }
.breakdown__head p { margin: var(--s-2) 0 0; font-size: var(--t-sm); color: var(--fg-dim); }
.breakdown__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.03fr) minmax(0, 1fr);   /* about equal heights */
  gap: var(--s-5);
  align-items: start;
}
.breakdown__final,
.breakdown__step { margin: 0; }
.breakdown__final video {
  display: block;
  width: 100%;
  aspect-ratio: 860 / 1080;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--ink);
}
.breakdown__steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-5);
}
.breakdown__step--wide { grid-column: 1 / -1; }
.breakdown__open {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-3);
  cursor: zoom-in;
  aspect-ratio: 860 / 1080;
}
.breakdown__step--wide .breakdown__open { aspect-ratio: 16 / 9; }
.breakdown__open img { width: 100%; height: 100%; object-fit: cover; }
.breakdown__cap { margin-top: var(--s-3); font-size: var(--t-sm); }
.breakdown__cap strong { font-weight: 600; }
.breakdown__cap span { display: block; color: var(--fg-dim); }

@media (max-width: 760px) {
  .breakdown__grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Lightbox ---------------------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;   /* minmax: tall media shrinks to fit */
  place-items: center;
  gap: var(--s-4);
  padding: clamp(3.5rem, 6vw, 4.5rem) clamp(1rem, 8vw, 5rem);
  background: rgba(16, 13, 9, 0.94);
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.lightbox__cap { font-size: var(--t-sm); color: var(--dark-dim); text-align: center; }
.lightbox__cap strong { color: var(--dark-fg); }
.lightbox__cap .label { color: var(--dark-dim); }
.lightbox__close,
.lightbox__nav {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--dark-1);
  border: 1px solid var(--dark-line);
  border-radius: 50%;
  color: var(--dark-fg);
  cursor: pointer;
  transition: background var(--dur-2) var(--ease);
}
.lightbox__close:hover,
.lightbox__nav:hover { background: #32363e; }
.lightbox__close:focus-visible,
.lightbox__nav:focus-visible { outline-color: var(--dark-fg); }
.lightbox__close { top: var(--s-4); right: var(--s-4); }
.lightbox__nav--prev { left: var(--s-3); top: 50%; transform: translateY(-50%); }
.lightbox__nav--next { right: var(--s-3); top: 50%; transform: translateY(-50%); }
