/* ==========================================================================
   Ram Miranda Cajiga — portfolio styles

   No framework and no build step. The whole look comes from a small set of
   tokens on :root (color, type scale, spacing); change a token and every
   component follows. Layout is mobile-first: one column by default, with
   Grid taking over once there is room.
   ========================================================================== */

/* Registered so it can be animated by a scroll timeline and inherited by the
   meter's children. JS writes the same property where scroll timelines are
   unsupported, so both paths drive one variable. */
@property --progress {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

/* ---------- Tokens ------------------------------------------------------- */

/* Every text color is at least 7:1 against --paper (WCAG AAA), muted text
   included. --accent is the single color in the palette and only marks
   progress and keyboard focus. */
:root {
  color-scheme: light dark;

  --paper: #f8f7f3;
  --ink: #121212;
  --muted: #3f3f3c;
  --rule: #c9c6bc; /* decorative hairlines only, never text */
  --accent: #0a5c53;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;

  /* Fluid type: each step grows smoothly with the viewport, no breakpoints. */
  --step--1: clamp(0.875rem, 0.85rem + 0.1vw, 0.9375rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1: clamp(1.2rem, 1.1rem + 0.5vw, 1.5rem);
  --step-2: clamp(1.5rem, 1.3rem + 1vw, 2.125rem);
  --step-3: clamp(2rem, 1.6rem + 2vw, 3.25rem);
  --step-4: clamp(2.5rem, 1.6rem + 4vw, 5rem);

  --space-xs: 0.5rem;
  --space-s: 1rem;
  --space-m: 1.5rem;
  --space-l: 2.5rem;
  --space-xl: clamp(4rem, 3rem + 5vw, 8rem);

  --gutter: 1rem;
  --rail: 0rem;
  --measure: 65ch;
  --header-h: 0rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111110;
    --ink: #f1efe8;
    --muted: #c9c6bc;
    --rule: #3d3c38;
    --accent: #6fd6c8;
  }
}

/* ---------- Base --------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-s));
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0) / 1.65 var(--font-sans);
}

h1,
h2,
h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.1;
  text-wrap: balance;
}

p,
li {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* One focus style for every interactive element: thick, offset, in the accent,
   at least 3:1 against the page in both themes. */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.wrap {
  width: min(100% - 2 * (var(--gutter) + var(--rail)), 60rem);
  margin-inline: auto;
}

.skip-link {
  position: absolute;
  top: var(--space-s);
  left: var(--space-s);
  z-index: 30;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---------- Header & nav ------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs) var(--space-m);
  padding-block: var(--space-xs);
}

.brand {
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 600;
  text-decoration: none;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-s);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* 44px-tall hit areas; the current chapter gets an underline bar. */
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  border-bottom: 2px solid transparent;
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
}

.site-nav a:hover,
.site-nav a[aria-current] {
  border-bottom-color: currentColor;
}

@media (min-width: 48rem) {
  :root {
    --header-h: 4rem;
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 10;
  }
}

/* ---------- Hero --------------------------------------------------------- */

.hero {
  padding-block: var(--space-xl);
}

.eyebrow {
  margin: 0 0 var(--space-s);
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: var(--step-4);
  letter-spacing: -0.015em;
  line-height: 1.02;
}

.hero__role {
  margin: var(--space-xs) 0 var(--space-l);
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: var(--step-2);
  font-style: italic;
}

.lead {
  max-width: 40ch;
  margin: 0 0 var(--space-m);
  font-size: var(--step-1);
  line-height: 1.5;
}

.hero__story {
  max-width: var(--measure);
  margin: 0 0 var(--space-l);
  color: var(--muted);
}

.hero__cue {
  display: inline-flex;
  gap: 0.5em;
  align-items: center;
  min-height: 2.75rem;
  font-weight: 600;
}

/* ---------- Chapters ------------------------------------------------------
   The level-up is told through weight alone: the top rule thickens, the badge
   goes from outline to solid to framed, and the XP bar fills. */

.chapter {
  --weight: 1px;
  --xp: 0.04;

  padding-block: var(--space-xl);
  border-top: var(--weight) solid var(--ink);
}

.chapter[data-level="50"] {
  --weight: 3px;
  --xp: 0.5;
}

.chapter[data-level="100"] {
  --weight: 9px;
  --xp: 1;

  border-top-style: double;
}

.chapter h2 {
  margin: 0 0 var(--space-s);
}

.chapter__level {
  display: inline-block;
  margin-bottom: var(--space-s);
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.4;
  text-transform: uppercase;
}

.chapter[data-level="50"] .chapter__level,
.chapter[data-level="100"] .chapter__level {
  background: var(--ink);
  color: var(--paper);
}

.chapter[data-level="100"] .chapter__level {
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink);
}

.chapter__title {
  display: block;
  font-size: var(--step-3);
}

.chapter__concept {
  max-width: 36ch;
  margin: 0;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-style: italic;
  line-height: 1.45;
}

.xp {
  max-width: 12rem;
  height: 6px;
  margin-top: var(--space-m);
  background: var(--rule);
}

.xp::after {
  content: "";
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(var(--xp));
  transform-origin: left;
}

.chapter__body {
  max-width: var(--measure);
}

.chapter__body > p:first-child {
  margin-top: 0;
}

.chapter h3 {
  margin: var(--space-l) 0 var(--space-s);
  font-size: var(--step-2);
}

.outcomes {
  display: grid;
  gap: var(--space-s);
  margin: 0;
  padding: 0;
  list-style: none;
}

.outcomes li {
  position: relative;
  padding-left: 1.5rem;
}

.outcomes li::before {
  content: "";
  position: absolute;
  top: 0.6em;
  left: 0;
  width: 0.5rem;
  height: 0.5rem;
  background: var(--ink);
}

.outcomes--feats {
  gap: var(--space-m);
}

/* Feats carry a heading, so a full-height rule replaces the square bullet. */
.outcomes--feats li {
  padding-left: 1.25rem;
  border-left: 3px solid var(--ink);
}

.outcomes--feats li::before {
  content: none;
}

.outcomes--feats strong {
  display: block;
  font-size: var(--step-1);
  font-family: var(--font-serif);
  font-weight: 600;
}

/* Technical detail lives behind a native disclosure: executives read the
   story, engineers can open the toolkit. */
.toolkit {
  margin-top: var(--space-l);
  padding-top: var(--space-s);
  border-top: 1px solid var(--rule);
}

.toolkit summary {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  cursor: pointer;
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.toolkit summary::marker,
.toolkit summary::-webkit-details-marker,
.inventory summary::marker,
.inventory summary::-webkit-details-marker {
  display: none;
  content: "";
}

.toolkit summary::before,
.inventory summary::before {
  content: "+";
  display: inline-block;
  width: 1.25em;
  font-size: 1.2em;
}

.toolkit[open] summary::before,
.inventory[open] summary::before {
  content: "−";
}

.toolkit p {
  margin: var(--space-xs) 0 0;
  color: var(--muted);
  font-size: var(--step--1);
}

@media (min-width: 48rem) {
  .chapter {
    display: grid;
    grid-template-columns: minmax(14rem, 2fr) 3fr;
    gap: var(--space-l);
  }

  /* The chapter heading stays in view while its story scrolls past. */
  .chapter__head {
    position: sticky;
    top: calc(var(--header-h) + var(--space-l));
    align-self: start;
  }
}

/* ---------- Scroll reveal ------------------------------------------------
   app.js adds .is-pending only to chapters below the fold, and only when the
   visitor has not asked for reduced motion. Without JS nothing is hidden. */

@media (prefers-reduced-motion: no-preference) {
  .chapter {
    transition: opacity 0.7s ease, translate 0.7s ease;
  }

  .xp::after {
    transition: transform 1.2s cubic-bezier(0.2, 0.7, 0.2, 1) 0.3s;
  }
}

.chapter.is-pending {
  opacity: 0;
  translate: 0 1.5rem;
}

.chapter.is-pending .xp::after {
  transform: scaleX(0);
}

/* ---------- Contact ------------------------------------------------------ */

.contact {
  padding-block: var(--space-xl);
  border-top: 1px solid var(--rule);
}

.contact h2 {
  margin: 0 0 var(--space-m);
  font-size: var(--step-3);
}

.cta-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
  margin: var(--space-l) 0 0;
  padding: 0;
  list-style: none;
}

.cta {
  display: inline-flex;
  align-items: center;
  min-height: 3rem;
  padding: 0.75rem 1.25rem;
  border: 2px solid var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.cta:hover,
.cta--primary {
  background: var(--ink);
  color: var(--paper);
}

.cta--primary:hover {
  background: var(--paper);
  color: var(--ink);
}

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

.site-footer {
  padding-block: var(--space-l);
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: var(--step--1);
}

.site-footer p {
  margin: 0 0 var(--space-xs);
}

.values {
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- Progress meter ------------------------------------------------
   Phones: a thin bar across the top. Wide screens: a vertical rail in the left
   gutter with Level 1 / 50 / 100 markers that fill as each chapter is reached. */

.meter {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  height: 4px;
  pointer-events: none;
}

.meter__fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(var(--progress));
  transform-origin: left;
}

.meter__marks {
  display: none;
}

@supports (animation-timeline: scroll()) {
  .meter {
    animation: progress linear both;
    animation-timeline: scroll(root block);
  }
}

@keyframes progress {
  from {
    --progress: 0;
  }

  to {
    --progress: 1;
  }
}

@media (min-width: 64rem) {
  :root {
    --rail: 5rem;
  }

  .meter {
    inset: 50% auto auto 2rem;
    width: 4rem;
    height: min(60vh, 28rem);
    translate: 0 -50%;
  }

  .meter__track,
  .meter__fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
  }

  .meter__track {
    background: var(--rule);
  }

  .meter__fill {
    transform: scaleY(var(--progress));
    transform-origin: top;
  }

  .meter__marks {
    position: absolute;
    inset: 0;
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .meter__mark {
    position: absolute;
    left: 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    white-space: nowrap;
    translate: -4px -50%;
  }

  .meter__mark::before {
    content: "";
    width: 10px;
    height: 10px;
    border: 2px solid var(--ink);
    border-radius: 50%;
    background: var(--paper);
  }

  .meter__mark--1 {
    top: 0;
  }

  .meter__mark--50 {
    top: 50%;
  }

  .meter__mark--100 {
    top: 100%;
  }

  /* app.js sets data-level on <html> to the chapter in view. */
  [data-level="1"] .meter__mark--1::before,
  [data-level="50"] :is(.meter__mark--1, .meter__mark--50)::before,
  [data-level="100"] .meter__mark::before {
    border-color: var(--accent);
    background: var(--accent);
  }

  [data-level="1"] .meter__mark--1,
  [data-level="50"] .meter__mark--50,
  [data-level="100"] .meter__mark--100 {
    color: var(--ink);
  }
}

/* ---------- Level characters ----------------------------------------------
   Pixel sprites generated by tools/sprites.py and inlined, so the effects
   below can target their SVG groups. They sit in a dark "game window" in both
   themes, which carries its own colors and focus accent. */

.sprite-frame {
  --accent: #6fd6c8;

  max-width: 16rem;
  margin: var(--space-m) 0 0;
  padding: var(--space-s);
  border: 1px solid #3a3040;
  background: #0d0a12;
  color: #ece6da;
}

.sprite {
  display: block;
  width: 100%;
  height: auto;
}

.inventory {
  margin-top: var(--space-xs);
  font-family: var(--font-serif);
}

.inventory summary {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.inventory__list {
  display: grid;
  gap: var(--space-xs);
  margin: var(--space-xs) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--step--1);
  line-height: 1.35;
}

.item__name {
  display: block;
  font-weight: 600;
}

.item__stat {
  color: #c4bcae;
}

/* Diablo-style rarity colors, each at least 7:1 on the window background. */
.item--common .item__name { color: #ece6da; }
.item--magic .item__name { color: #a3adff; }
.item--rare .item__name { color: #f2e05a; }
.item--unique .item__name { color: #d6b36a; }
.item--set .item__name { color: #4fdc5a; }
.item--skill .item__name { color: #6fe8d8; }

.sprite__bolt--b,
.sprite__glint {
  opacity: 0;
}

/* Frame-stepped loops, like an old console: no tweening between pixels. */
@media (prefers-reduced-motion: no-preference) {
  .sprite__body {
    animation: sprite-bob 1.6s steps(1, end) infinite;
  }

  .sprite__gem {
    animation: sprite-pulse 1.2s steps(2, jump-none) infinite alternate;
  }

  .sprite__aura {
    animation: sprite-aura 2.4s steps(4, jump-none) infinite alternate;
  }

  .sprite__aura--outer,
  .sprite--50 .sprite__aura {
    animation-name: sprite-aura-faint;
  }

  .sprite__leak {
    animation: sprite-flare 3.2s steps(1, end) infinite;
  }

  .sprite__bolt--a {
    animation: sprite-blink 0.9s steps(1, end) infinite;
  }

  .sprite__bolt--b {
    animation: sprite-blink 0.9s steps(1, end) infinite reverse;
  }

  .sprite__glint {
    animation: sprite-glint 3.6s steps(1, end) infinite;
  }

  .sprite__glint--2 { animation-delay: 0.12s; }
  .sprite__glint--3 { animation-delay: 0.24s; }

  .sprite__minion {
    animation: sprite-bob 0.8s steps(1, end) infinite;
  }

  .sprite__minion:nth-of-type(even) { animation-delay: -0.4s; }
  .sprite__minion:nth-of-type(3n) { animation-duration: 1s; }
}

@keyframes sprite-bob {
  50% { transform: translateY(1px); }
}

@keyframes sprite-pulse {
  from { opacity: 0.2; }
  to { opacity: 1; }
}

@keyframes sprite-aura {
  from { opacity: 0.1; }
  to { opacity: 0.4; }
}

@keyframes sprite-aura-faint {
  from { opacity: 0.05; }
  to { opacity: 0.2; }
}

@keyframes sprite-flare {
  0% { opacity: 0.45; }
  70% { opacity: 1; }
  76% { opacity: 0.45; }
  82% { opacity: 1; }
  88% { opacity: 0.45; }
}

@keyframes sprite-blink {
  0% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes sprite-glint {
  0% { opacity: 1; }
  8% { opacity: 0; }
}

/* ---------- Print -------------------------------------------------------- */

@media print {
  .meter,
  .skip-link,
  .site-nav,
  .hero__cue {
    display: none;
  }

  .site-header {
    position: static;
  }

  .chapter {
    display: block;
    break-inside: avoid;
  }

  .chapter.is-pending {
    opacity: 1;
    translate: none;
  }

  .cta-list a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-weight: 400;
  }
}
