:root {
  color-scheme: dark;
  --void: #07080a;
  --steel: #1d2025;
  --hairline: rgba(214, 219, 226, .26);
  --silver: #d6dbe2;
  --dim: #9aa1ab;
  --white: #f7f9fc;
  --chrome: linear-gradient(180deg, #ffffff 0%, #c2c8d1 36%, #f5f7fa 49%, #3a3e46 52%, #8e959f 72%, #eef1f5 100%);
  --gothic: "Grenze Gotisch", "Old English Text MT", Georgia, serif;
  --euro: "Michroma", "Eurostile", "Arial", sans-serif;
  --gutter: clamp(16px, 3vw, 40px);
  --cut: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: radial-gradient(ellipse 70% 62% at 50% 42%, #272a30 0%, #101216 55%, var(--void) 100%);
  color: var(--silver);
  font-family: var(--euro);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible { outline: 2px solid var(--white); outline-offset: 3px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;
}

#stage:focus-visible { outline: none; }
body[data-mode="index"] #stage { display: none; }

/* Header */

.bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 3;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 18px var(--gutter);
  pointer-events: none;
}

.bar > * { pointer-events: auto; }

.wordmark {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  font-family: var(--gothic);
  font-size: 34px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
}

.wordmark-sigil { width: 20px; height: 30px; fill: var(--silver); }

.filters, .switch { display: flex; }

.filters { gap: 4px; }

.filters button, .switch button, .viewer-thumbs button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: .04em;
  clip-path: var(--cut);
  transition: color .15s ease, background .15s ease;
}

.filters button:hover, .switch button:hover, .viewer-thumbs button:hover { color: var(--white); }

.filters button[aria-pressed="true"], .switch button[aria-pressed="true"], .viewer-thumbs button[aria-pressed="true"] {
  background: var(--silver);
  color: var(--void);
}

.bar-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 18px;
}

.link-button {
  min-height: 40px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--silver);
  font-size: 12px;
  letter-spacing: .04em;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.link-button:hover { color: var(--white); }

/* Selected-project readout */

.hud {
  position: fixed;
  inset: auto 0 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 var(--gutter) clamp(18px, 3vh, 32px);
  pointer-events: none;
}

.hud > * { pointer-events: auto; }

.hud-text { min-width: 0; }

.hud-count {
  display: flex;
  gap: 20px;
  margin: 0;
  color: var(--dim);
  font-size: 12px;
  letter-spacing: .04em;
}

.hud-title {
  margin: 0;
  font-family: var(--gothic);
  font-size: clamp(52px, 8.4vh, 96px);
  font-weight: 700;
  line-height: 1.12;
}

.hud-title button {
  display: block;
  max-width: 100%;
  padding: 0 .08em 0 0;
  border: 0;
  background: var(--chrome);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: left;
}

.hud-controls { display: flex; flex: none; gap: 6px; padding-bottom: 14px; }

.icon-button, .solid-button {
  min-height: 46px;
  border: 0;
  clip-path: var(--cut);
  font-size: 12px;
  letter-spacing: .04em;
  transition: background .15s ease, color .15s ease;
}

.icon-button {
  width: 46px;
  background: var(--steel);
  color: var(--white);
  font-family: Arial, sans-serif;
  font-size: 18px;
}

.icon-button:hover { background: #363a41; }

.solid-button {
  padding: 0 22px;
  background: linear-gradient(180deg, #ffffff, #b4bac4);
  color: var(--void);
}

.solid-button:hover { background: var(--white); }

/* Index view */

.index {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow-y: auto;
  padding: 96px var(--gutter) 48px;
  background: var(--void);
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 36px 20px;
}

.index-card {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
}

.index-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--steel);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  transition: filter .2s ease;
}

.index-card:hover img { filter: brightness(1.15); }

.index-number { display: block; margin-top: 12px; color: var(--dim); font-size: 12px; letter-spacing: .04em; }

.index-title {
  display: block;
  color: var(--white);
  font-family: var(--gothic);
  font-size: 38px;
  font-weight: 500;
  line-height: 1.15;
}

/* Project viewer */

dialog { color: inherit; }

.viewer {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--void);
}

.viewer[open] {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  animation: fade .24s ease both;
}

.viewer-media {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: var(--gutter);
}

.viewer-frame { flex: 1; min-height: 0; display: grid; place-items: center; }

.viewer-frame img, .viewer-frame video {
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  display: block;
  object-fit: contain;
}

.viewer-frame img, .viewer-frame video { width: auto; height: auto; }
.viewer-frame iframe { width: 100%; max-height: 100%; aspect-ratio: 16 / 9; border: 0; }

.viewer-thumbs { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 14px; }

.viewer-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 18px var(--gutter) var(--gutter);
  border-left: 1px solid var(--hairline);
}

.viewer-close { align-self: flex-end; }

.viewer-copy { margin-top: auto; }

.viewer-side h2, .info h2 {
  margin: 10px 0 18px;
  background: var(--chrome);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-family: var(--gothic);
  font-size: clamp(56px, 6vw, 84px);
  font-weight: 700;
  line-height: 1.04;
}

.viewer-text { margin: 0; color: var(--silver); font-size: 13px; line-height: 1.85; }

.viewer-sample {
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
  color: var(--dim);
  font-size: 12px;
  line-height: 1.7;
}

.viewer-nav { display: flex; gap: 6px; margin-top: 28px; }

/* Info panel */

.info {
  width: min(460px, 100vw);
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 18px var(--gutter) var(--gutter);
  border: 0;
  border-left: 1px solid var(--hairline);
  background: var(--void);
}

.info[open] { display: flex; flex-direction: column; animation: fade .2s ease both; }
.info::backdrop, .viewer::backdrop { background: rgba(3, 4, 5, .72); }
.info h2 { margin-top: auto; }

.info-links { margin: 24px 0 0; padding: 0; list-style: none; }
.info-links li + li { margin-top: 10px; }
.info-links a { color: var(--white); text-underline-offset: 5px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 860px) {
  .bar { grid-template-columns: 1fr auto; padding-top: 12px; row-gap: 4px; }
  .filters { grid-row: 2; grid-column: 1 / -1; justify-self: start; }
  .filters button { padding: 0 12px; }
  .switch button { padding: 0 12px; }
  .bar-actions { gap: 12px; }
  .index { padding-top: 128px; }

  .hud { flex-direction: column; align-items: stretch; gap: 8px; }
  .hud-title { font-size: clamp(48px, 15vw, 72px); line-height: 1.08; }
  .hud-controls { padding-bottom: 0; }
  .solid-button { flex: 1; }

  .viewer[open] { display: block; overflow-y: auto; }
  .viewer-media { height: 62dvh; padding: 16px; }
  .viewer-side { min-height: 38dvh; overflow: visible; padding-top: 8px; border-top: 1px solid var(--hairline); border-left: 0; }
  .viewer-close { position: fixed; top: 8px; right: 16px; z-index: 1; padding: 0 12px; background: var(--void); }
  .viewer-copy { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
