/* Josiah Koplick — house index.
   Iron, parchment, and gold, shared with The Hidden Forge.
   A forge at night: embers rise, the name is poured in gold,
   and each door warms under the hand. */

:root {
  --ink: #100e0b;
  --ink-deep: #0a0907;
  --ink-card: #17130e;
  --ink-card-hot: #221a11;
  --parchment: #ece2c6;
  --parchment-soft: #c3b596;
  --gold: #b8894a;
  --gold-bright: #d9a45c;
  --gold-white: #fff1cf;
  --ember: #e0662f;
  --blood: #7a2420;
  --iron: #3a352a;
  --iron-soft: rgba(58, 53, 42, 0.55);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, "Courier New", monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --x: 50vw;
  --y: 40vh;
}

* { box-sizing: border-box; }

html {
  background: var(--ink-deep);
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(120% 80% at 50% 120%, rgba(122, 36, 32, 0.38), transparent 60%),
    radial-gradient(80% 60% at 10% -10%, rgba(217, 164, 92, 0.12), transparent 60%),
    var(--ink);
  color: var(--parchment);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  padding: 0.4rem 0.7rem;
  background: var(--gold-bright);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.skip:focus { top: 1rem; }

/* ---------- Atmosphere layers ---------- */

#embers {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(28rem 28rem at var(--x) var(--y), rgba(217, 164, 92, 0.09), transparent 70%);
  transition: opacity 600ms ease;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.09;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.93  0 0 0 0 0.88  0 0 0 0 0.77  0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}

.frame {
  position: fixed;
  inset: clamp(0.6rem, 1.6vw, 1.25rem);
  z-index: 2;
  pointer-events: none;
  border: 1px solid var(--iron-soft);
}

.frame::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(58, 53, 42, 0.3);
}

.corner {
  position: absolute;
  width: 1.4rem;
  height: 1.4rem;
  border-color: var(--gold);
  border-style: solid;
  border-width: 0;
}

.corner.tl { top: -1px; left: -1px; border-top-width: 1px; border-left-width: 1px; }
.corner.tr { top: -1px; right: -1px; border-top-width: 1px; border-right-width: 1px; }
.corner.bl { bottom: -1px; left: -1px; border-bottom-width: 1px; border-left-width: 1px; }
.corner.br { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

.corner::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  background: var(--gold-bright);
  transform: rotate(45deg);
}

.corner.tl::after { top: -3px; left: -3px; }
.corner.tr::after { top: -3px; right: -3px; }
.corner.bl::after { bottom: -3px; left: -3px; }
.corner.br::after { bottom: -3px; right: -3px; }

/* ---------- Stage ---------- */

.stage {
  position: relative;
  z-index: 3;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(2.6rem, calc(env(safe-area-inset-top) + 1.6rem))
    max(2.4rem, calc(env(safe-area-inset-right) + 1.6rem))
    max(2rem, calc(env(safe-area-inset-bottom) + 1.4rem))
    max(2.4rem, calc(env(safe-area-inset-left) + 1.6rem));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: min(70rem, 100%);
  margin: 0 auto;
  color: var(--gold-bright);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  animation: fade 1.2s ease 0.1s backwards;
}

.topbar .rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--iron), rgba(184, 137, 74, 0.5), var(--iron));
}

.live::before {
  content: "";
  display: inline-block;
  width: 0.42rem;
  height: 0.42rem;
  margin-right: 0.6rem;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 10px var(--ember);
  vertical-align: 0.05em;
  animation: pulse 2.6s ease-out infinite;
}

.wrap {
  width: min(70rem, 100%);
  margin: auto;
  padding: clamp(2rem, 5vh, 3.5rem) 0;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(2.5rem, 6vw, 5.5rem);
  align-items: center;
}

/* ---------- Masthead ---------- */

.mast { position: relative; }

.seal {
  display: block;
  width: clamp(5.5rem, 9vw, 7.5rem);
  height: auto;
  margin: 0 0 1.6rem -0.35rem;
  overflow: visible;
  animation: seal-in 1.4s var(--ease) backwards;
}

.seal-line {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1;
  opacity: 0.6;
}

.seal-spin {
  transform-origin: 100px 100px;
  animation: spin 48s linear infinite;
}

.seal-text {
  fill: var(--gold-bright);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.seal-mono {
  font-family: var(--display);
  font-size: 58px;
  font-style: italic;
  font-weight: 500;
  font-variation-settings: "opsz" 144;
  text-anchor: middle;
  dominant-baseline: central;
  letter-spacing: -0.04em;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 1rem;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.kicker::after {
  content: "";
  width: 3rem;
  height: 1px;
  background: var(--gold);
  opacity: 0.6;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3.8rem, 8.6vw, 7.6rem);
  font-weight: 400;
  font-variation-settings: "opsz" 144;
  letter-spacing: -0.045em;
  line-height: 0.9;
}

h1 .line { display: block; }

h1 .one {
  animation: rise-fast 0.7s var(--ease) backwards;
}

h1 .two {
  padding-left: 0.9em;
  font-style: italic;
  font-weight: 300;
  animation: rise-fast 0.7s var(--ease) 0.06s backwards;
}

.molten {
  display: inline-block;
  padding: 0 0.08em 0.12em 0;
  background: linear-gradient(
    100deg,
    #7a4a1e 0%,
    var(--gold) 18%,
    var(--gold-bright) 32%,
    var(--gold-white) 42%,
    var(--gold-bright) 50%,
    var(--ember) 64%,
    var(--blood) 78%,
    var(--gold) 100%
  );
  background-size: 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 28px rgba(224, 102, 47, 0.28));
  animation: pour 11s ease-in-out infinite alternate;
}

.lede {
  position: relative;
  max-width: 27rem;
  margin: 2rem 0 0;
  padding-left: 1.25rem;
  color: var(--parchment-soft);
  font-size: 1.24rem;
  font-style: italic;
  line-height: 1.5;
  text-wrap: pretty;
  animation: rise-fast 0.7s var(--ease) 0.12s backwards;
}

.lede::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.35em;
  bottom: 0.35em;
  width: 1px;
  background: linear-gradient(var(--gold-bright), var(--blood));
}

/* ---------- Doors ---------- */

#places {
  display: flex;
  flex-direction: column;
  counter-reset: door;
}

.door {
  --mx: 50%;
  --my: 50%;
  position: relative;
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
  min-height: 5.2rem;
  padding: 1rem 1.15rem 1rem 1rem;
  border-top: 1px solid var(--iron);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  animation: rise-lite 0.9s var(--ease) backwards;
  transition: background-color 300ms ease;
  -webkit-tap-highlight-color: transparent;
}

.door:last-child { border-bottom: 1px solid var(--iron); }

.door:nth-child(1) { animation-delay: 0.45s; }
.door:nth-child(2) { animation-delay: 0.55s; }
.door:nth-child(3) { animation-delay: 0.65s; }
.door:nth-child(4) { animation-delay: 0.75s; }
.door:nth-child(5) { animation-delay: 0.85s; }

/* heat that follows the pointer inside the door */
.door::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(16rem 9rem at var(--mx) var(--my), rgba(224, 102, 47, 0.2), transparent 70%),
    linear-gradient(90deg, rgba(36, 28, 18, 0.95), rgba(23, 19, 14, 0.6));
  opacity: 0;
  transition: opacity 320ms ease;
}

/* a gold seam that is drawn across on hover */
.door::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-bright) 30%, var(--gold-white) 50%, var(--gold-bright) 70%, transparent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 520ms var(--ease);
}

.door:focus-visible::before { opacity: 1; }

.door:focus-visible::after { transform: scaleX(1); }

.door:focus-visible {
  outline: 1px solid var(--gold-bright);
  outline-offset: 4px;
}

.idx {
  color: var(--gold);
  font-family: var(--display);
  font-size: 1.05rem;
  font-style: italic;
  font-weight: 400;
  text-align: center;
  transition: color 300ms ease, text-shadow 300ms ease;
}

.copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.title {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 400;
  font-variation-settings: "opsz" 72;
  letter-spacing: -0.02em;
  line-height: 1.1;
  transition: letter-spacing 400ms var(--ease), color 300ms ease, translate 400ms var(--ease);
}

.note {
  color: var(--parchment-soft);
  font-size: 0.96rem;
  opacity: 0.85;
  transition: opacity 300ms ease;
}

.go {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  transition: color 300ms ease;
}

.go i {
  font-style: normal;
  display: inline-block;
  transition: translate 400ms var(--ease);
}

.door:focus-visible .title {
  color: var(--gold-white);
  font-style: italic;
  letter-spacing: -0.01em;
  translate: 6px 0;
}

.door:focus-visible .idx {
  color: var(--gold-bright);
  text-shadow: 0 0 14px rgba(224, 102, 47, 0.7);
}

.door:focus-visible .note { opacity: 1; }

.door:focus-visible .go { color: var(--gold-bright); }

.door:focus-visible .go i { translate: 5px 0; }

/* ---------- Latest essays ---------- */

.latest {
  grid-column: 1 / -1;
  padding-top: clamp(1rem, 3vh, 2rem);
}

.latest[hidden] { display: none; }

.latest-h {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.4rem;
  color: var(--gold-bright);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.latest-h::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(184, 137, 74, 0.5), var(--iron) 60%, transparent);
}

.essays {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.essay {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  height: 100%;
  padding: 1.15rem 1.2rem 1.3rem;
  border: 1px solid var(--iron);
  background: rgba(23, 19, 14, 0.7);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  animation: rise-lite 0.9s var(--ease) backwards;
  transition: border-color 300ms ease, background-color 300ms ease;
}

.essay::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-bright) 30%, var(--gold-white) 50%, var(--gold-bright) 70%, transparent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 520ms var(--ease);
}

.essay:focus-visible {
  border-color: rgba(184, 137, 74, 0.6);
  background: var(--ink-card-hot);
}

.essay:focus-visible::after { transform: scaleX(1); }

.essay:focus-visible {
  outline: 1px solid var(--gold-bright);
  outline-offset: 4px;
}

.e-date {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.e-title {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 400;
  font-variation-settings: "opsz" 72;
  letter-spacing: -0.015em;
  line-height: 1.2;
  text-wrap: balance;
  transition: color 300ms ease;
}

.essay:focus-visible .e-title {
  color: var(--gold-white);
  font-style: italic;
}

.e-sub {
  color: var(--parchment-soft);
  font-size: 0.95rem;
  font-style: italic;
  line-height: 1.45;
  opacity: 0.85;
}

.latest-all {
  display: inline-flex;
  gap: 0.5rem;
  margin-top: 1.1rem;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: color 300ms ease;
}

.latest-all i { font-style: normal; transition: translate 400ms var(--ease); }

/* ---------- 404 ---------- */

.lost h1 { font-size: clamp(3.2rem, 7vw, 6.4rem); }

.lost-num {
  margin: 0 0 0.6rem -0.04em;
  font-family: var(--display);
  font-size: clamp(5rem, 11vw, 9rem);
  font-style: italic;
  font-weight: 300;
  font-variation-settings: "opsz" 144;
  line-height: 0.85;
  letter-spacing: -0.05em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(184, 137, 74, 0.55);
  animation: rise-fast 0.7s var(--ease) backwards;
}

.lost .door:first-child .idx { font-style: normal; }

/* ---------- Hover (mouse and trackpad only) ---------- */

@media (hover: hover) {
  .door:hover::before { opacity: 1; }

  .door:hover::after { transform: scaleX(1); }

  .door:hover .title {
    color: var(--gold-white);
    font-style: italic;
    letter-spacing: -0.01em;
    translate: 6px 0;
  }

  .door:hover .idx {
    color: var(--gold-bright);
    text-shadow: 0 0 14px rgba(224, 102, 47, 0.7);
  }

  .door:hover .note { opacity: 1; }

  .door:hover .go { color: var(--gold-bright); }

  .door:hover .go i { translate: 5px 0; }

  .essay:hover {
    border-color: rgba(184, 137, 74, 0.6);
    background: var(--ink-card-hot);
  }

  .essay:hover::after { transform: scaleX(1); }

  .essay:hover .e-title {
    color: var(--gold-white);
    font-style: italic;
  }

  .latest-all:hover { color: var(--gold-bright); }

  .latest-all:hover i { translate: 5px 0; }
}

/* ---------- Footer ---------- */

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: min(70rem, 100%);
  margin: 0 auto;
  color: rgba(195, 181, 150, 0.55);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  animation: fade 1.2s ease 1s backwards;
}

.foot-mark { color: var(--gold); }

/* ---------- Motion ---------- */

/* The name and tagline are the first thing a visitor sees, so they start
   moving at once and without blur; the browser counts the page as shown
   as soon as they paint. */
@keyframes rise-fast {
  from { opacity: 0; translate: 0 10px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes rise-lite {
  from { opacity: 0; translate: 0 18px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes rise {
  from { opacity: 0; translate: 0 18px; filter: blur(6px); }
  to { opacity: 1; translate: 0 0; filter: blur(0); }
}

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

@keyframes seal-in {
  from { opacity: 0; transform: rotate(-40deg) scale(0.85); }
  to { opacity: 1; transform: none; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pour {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(224, 102, 47, 0.55), 0 0 10px var(--ember); }
  70% { box-shadow: 0 0 0 9px rgba(224, 102, 47, 0), 0 0 10px var(--ember); }
  100% { box-shadow: 0 0 0 0 rgba(224, 102, 47, 0), 0 0 10px var(--ember); }
}

@keyframes grain {
  0% { background-position: 0 0; }
  20% { background-position: -40px 25px; }
  40% { background-position: 30px -55px; }
  60% { background-position: -60px -15px; }
  80% { background-position: 45px 40px; }
  100% { background-position: 0 0; }
}

/* ---------- Small screens ---------- */

@media (max-width: 52rem) {
  .stage {
    padding:
      max(2rem, calc(env(safe-area-inset-top) + 1.4rem))
      max(1.6rem, calc(env(safe-area-inset-right) + 1.2rem))
      max(1.6rem, calc(env(safe-area-inset-bottom) + 1.2rem))
      max(1.6rem, calc(env(safe-area-inset-left) + 1.2rem));
  }

  .wrap {
    grid-template-columns: 1fr;
    gap: 2.6rem;
  }

  .seal { width: 5rem; margin-bottom: 1.2rem; }

  h1 .two { padding-left: 0.6em; }

  .go { display: none; }

  .door {
    grid-template-columns: 2rem minmax(0, 1fr);
    min-height: 4.6rem;
    padding-left: 0.4rem;
  }

  .title { font-size: 1.5rem; }

  .essays { grid-template-columns: 1fr; }

  .foot { flex-wrap: wrap; gap: 0.5rem 0.8rem; }

  .glow { display: none; }
}

@media (hover: none) {
  .glow { display: none; }
}

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

  #embers { display: none; }

  .molten { background-position: 40% 50%; }

  .door:hover .title,
  .door:focus-visible .title { translate: none; }
}

@media print {
  #embers,
  .glow,
  .grain,
  .frame,
  .topbar,
  .seal,
  .go,
  .latest-all,
  .skip { display: none; }

  body { background: #fff; color: #111; }

  .molten { color: #111; background: none; filter: none; }

  .kicker,
  .lede,
  .note,
  .idx,
  .foot { color: #333; }

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