/*
 * Sedimento: "Día" (light) and "Noche" (dark), same tokens as harelolguin.dev
 * (web-portfolio/src/styles/global.css). Every color holds both values via light-dark(),
 * so the OS preference drives the theme with pure CSS; the toggle only sets data-theme.
 */
:root {
  color-scheme: light dark;

  --bg: light-dark(#eee8dc, #12150f);
  --bg-raised: light-dark(#f6f2ea, #1a1e17);
  --bg-sunken: light-dark(#e4dccb, #0d0f0b);
  --ink: light-dark(#1c1f1a, #e8e2d4);
  --ink-muted: light-dark(#4d5247, #adac9c);
  --ink-faint: light-dark(#666a5e, #85877a); /* only on bg / bg-raised */
  --rule: light-dark(#d3cab6, #2a2f25); /* decorative only */
  --rule-strong: light-dark(#857c6a, #6a7162);
  --moss: light-dark(#3d5a30, #a3bd84);
  --on-moss: light-dark(#f4f0e6, #12150f);
  --oxide: light-dark(#9e4119, #e8865a);
  --ochre: light-dark(#d9a53a, #e3b451); /* highlighter background, never text */
  --on-ochre: light-dark(#1c1f1a, #12150f);
  --clay: light-dark(#d8c3a5, #3a3428);
  --focus: var(--oxide);

  --shadow-stamp: 3px 3px 0 0 light-dark(#1c1f1a, #a3bd84);
  --radius-1: 2px;
  --font-mono: "Fira Code", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-feature-settings: "calt" 1, "liga" 1;
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--ochre);
  color: var(--on-ochre);
}

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

/* ── status bar ─────────────────────────────────────────── */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--rule);
  font-size: 0.8125rem;
}

.me {
  font-weight: 600;
}

.me i {
  font-style: normal;
  color: var(--ink-faint);
}

.theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-1);
  cursor: pointer;
  transition: border-color 0.12s;
}

.theme:hover {
  border-color: var(--ink);
}

/* ── page ───────────────────────────────────────────────── */

.page {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

/* ── hero card: the avatar standing on his strata ───────── */

.hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  border: 1px solid var(--ink);
  background: var(--bg-raised);
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 20px 20px 0;
  border-right: 1px solid var(--ink);
  background-color: var(--bg-sunken);
  background-image: repeating-linear-gradient(45deg, var(--rule) 0 1px, transparent 1px 7px);
}

.avatar {
  display: block;
  image-rendering: pixelated;
  position: relative;
  z-index: 1;
}

/* Three bands, each with its own hatch angle so they read apart without relying on color. */
.strata {
  display: grid;
  width: calc(100% + 40px);
  margin: 0 -20px;
  border-top: 1px solid var(--ink);
}

.s {
  display: block;
  border-bottom: 1px solid var(--ink);
  background-color: var(--bg-raised);
}

.s:last-child {
  border-bottom: 0;
}

.s1 {
  height: 18px;
  background-image: repeating-linear-gradient(45deg, var(--moss) 0 2px, transparent 2px 6px);
}

.s2 {
  height: 12px;
  background-image: repeating-linear-gradient(-45deg, var(--ochre) 0 2px, transparent 2px 6px);
}

.s3 {
  height: 8px;
  background-image: repeating-linear-gradient(0deg, var(--clay) 0 2px, transparent 2px 5px);
}

.intro {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  padding: 20px;
}

.intro h1 {
  margin: 0 0 8px;
  font-size: 1.625rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.intro p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--ink-muted);
}

.intro .stack {
  font-size: 0.75rem;
  color: var(--ink-faint);
}

mark {
  background: var(--ochre);
  color: var(--on-ochre);
  padding: 0 0.15em;
}

.cursor {
  color: var(--oxide);
  font-weight: 400;
  margin-left: 2px;
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* In the dark theme bg-sunken is as dark as the hair and clothes; lift the stage. */
:root[data-theme="dark"] .stage {
  background-color: var(--rule-strong);
  background-image: repeating-linear-gradient(45deg, var(--ink-faint) 0 1px, transparent 1px 7px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .stage {
    background-color: var(--rule-strong);
    background-image: repeating-linear-gradient(45deg, var(--ink-faint) 0 1px, transparent 1px 7px);
  }
}

/* ── section rule ───────────────────────────────────────── */

.rule {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 40px 0 16px;
  font-size: 0.75rem;
  line-height: 1.4;
  font-weight: 500;
  letter-spacing: 0.06em;
}

.rule .n {
  color: var(--oxide);
}

.rule .line {
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.rule .count {
  color: var(--ink-faint);
  font-weight: 400;
}

/* ── links ──────────────────────────────────────────────── */

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.link {
  display: grid;
  grid-template-columns: 20px auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  color: var(--ink);
  text-decoration: none;
  background: var(--bg-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-1);
  transition:
    transform 0.12s,
    box-shadow 0.12s,
    border-color 0.12s;
}

.link:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-stamp);
  border-color: var(--ink);
}

.icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  color: var(--ink-muted);
}

.glyph {
  text-align: center;
  font-weight: 700;
}

.name {
  font-weight: 500;
}

.path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.go {
  color: var(--ink-muted);
  transition: transform 0.12s;
}

.link:hover .go {
  transform: translate(2px, -2px);
}

.link.primary {
  background: var(--moss);
  border-color: var(--moss);
  color: var(--on-moss);
}

.link.primary .path,
.link.primary .go {
  color: var(--on-moss);
}

.link.primary:hover .go {
  transform: translateX(3px);
}

/* ── footer status line ─────────────────────────────────── */

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 8px 16px;
  border-top: 1px solid var(--rule);
  font-size: 0.6875rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
}

.status .mode {
  color: var(--on-moss);
  background: var(--moss);
  padding: 0 6px;
  font-weight: 600;
}

/* ── entrance: sedimentation ────────────────────────────────
 * Layers deposit oldest first (bottom band → top band), then he lands on them,
 * then the intro, the rule and each link settle in order. ~1.3s in total.
 */

.stage {
  overflow: hidden;
}

.hero {
  animation: settle 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.s {
  transform-origin: left;
  animation: deposit 0.3s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.s3 {
  animation-delay: 0.2s;
}

.s2 {
  animation-delay: 0.32s;
}

.s1 {
  animation-delay: 0.44s;
}

/* steps() keeps the fall chunky, like the pixel art itself. */
.avatar {
  animation: land 0.42s steps(6, end) 0.6s both;
}

.intro > * {
  animation: settle 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.intro > :nth-child(1) {
  animation-delay: 0.75s;
}

.intro > :nth-child(2) {
  animation-delay: 0.83s;
}

.intro > :nth-child(3) {
  animation-delay: 0.91s;
}

.rule {
  animation: settle 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) 0.9s both;
}

.rule .line {
  transform-origin: left;
  animation: deposit 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) 1s both;
}

.links li {
  animation: settle 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(0.95s + var(--i, 0) * 0.06s);
}

@keyframes settle {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

@keyframes deposit {
  from {
    transform: scaleX(0);
  }
}

@keyframes land {
  /* Starts above the stage; overflow: hidden keeps it out of sight until it drops. */
  from {
    transform: translateY(-110%);
  }
  80% {
    transform: translateY(4px);
  }
}

/* ── small screens ──────────────────────────────────────── */

@media (max-width: 360px) {
  .path {
    display: none;
  }

  .link {
    grid-template-columns: 20px minmax(0, 1fr) auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor,
  .hero,
  .s,
  .avatar,
  .intro > *,
  .rule,
  .rule .line,
  .links li {
    animation: none;
  }

  .link,
  .link:hover,
  .link:hover .go {
    transform: none;
    transition: none;
  }
}
