/* vaed.com — cream canvas, warm ink, burnished gold */
/* Chess pieces: "Merida" by Armando Hernández Marroquín, GPLv2+ (via lichess-org/lila) */
/* A committed single-theme world: cream canvas, warm ink, burnished gold. */
  :root {
    --cream: #f6f1e7;
    --ink: #2a2620;
    --soft: #8a8172;
    --faint: #dcd4c4;
    --gold: #a8823f;
    --serif: "Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --sans: "Avenir Next", "Futura", "Helvetica Neue", Helvetica, sans-serif;
  }
  html { background: var(--cream); }
  * { -webkit-tap-highlight-color: transparent; }
  .candlelight {
    --cream: #f1e9d6;
    --faint: #d6cab2;
    --gold: #b08434;
    --soft: #857b68;
  }
  body {
    margin: 0;
    background: var(--cream);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
  }
  a { color: inherit; text-decoration: none; }
  a:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

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

  /* ————— Nav ————— */
  .nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 20;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 30px 40px;
    box-sizing: border-box;
  }
  .nav .brand {
    font-family: var(--serif);
    font-size: 17px;
    letter-spacing: 0.02em;
  }
  .nav .links { display: flex; gap: 34px; }
  .nav .links a {
    font-size: 11.5px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--soft);
    padding-bottom: 3px;
    border-bottom: 1px solid transparent;
    transition: color 0.25s ease, border-color 0.25s ease;
  }
  .nav .links a:hover { color: var(--ink); }
  .nav .links a.active { color: var(--ink); border-color: var(--gold); }

  /* ————— Pages ————— */
  .page {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    min-height: 100svh;
    display: none;
    box-sizing: border-box;
  }
  .page.visible { display: flex; animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
  }

  /* Home */
  #page-home {
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 100px 24px 80px;
  }
  .home-inner { max-width: 640px; }
  .tagline {
    font-family: var(--serif);
    font-size: clamp(23px, 3.6vw, 31px);
    font-weight: 400;
    line-height: 1.7;
    margin: 0;
    text-wrap: balance;
  }
  .tagline em { font-style: italic; color: var(--gold); }
  #agentic {
    cursor: pointer;
    padding-bottom: 0.3em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 16' preserveAspectRatio='none'%3E%3Cpath d='M 5.0 8.0 L 7.0 10.5 L 9.0 11.12 L 11.0 9.39 L 13.0 6.61 L 15.0 4.88 L 17.0 5.5 L 19.0 8.0 L 21.0 10.5 L 23.0 11.12 L 25.0 9.39 L 27.0 6.61 L 29.0 4.88 L 31.0 5.5 L 33.0 8.0 L 35.0 10.5 L 37.0 11.12 L 39.0 9.39 L 41.0 6.61 L 43.0 4.88 L 45.0 5.5 L 47.0 8.0 L 49.0 10.5 L 51.0 11.12 L 53.0 9.39 L 55.0 6.61 L 57.0 4.88 L 59.0 5.5 L 61.0 8.0 L 63.0 10.5 L 65.0 11.12 L 67.0 9.39 L 69.0 6.61 L 71.0 4.88 L 73.0 5.5 L 75.0 8.0 L 77.0 10.5 L 79.0 11.12 L 81.0 9.39 L 83.0 6.61 L 85.0 4.88 L 87.0 5.5 L 89.0 8.0 L 91.0 10.5 L 93.0 11.12 L 95.0 9.39 L 97.0 6.61 L 99.0 4.88 L 101.0 5.5 L 103.0 8.0 L 105.0 10.5 L 107.0 11.12 L 109.0 9.39 L 111.0 6.61 L 113.0 4.88 L 115.0 5.5' fill='none' stroke='%232a2620' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0 100%;
    background-size: 100% 0.22em;
    transition: color 0.3s ease;
  }
  #agentic:hover {
    color: var(--gold);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 16' preserveAspectRatio='none'%3E%3Cpath d='M 5.0 8.0 L 7.0 10.5 L 9.0 11.12 L 11.0 9.39 L 13.0 6.61 L 15.0 4.88 L 17.0 5.5 L 19.0 8.0 L 21.0 10.5 L 23.0 11.12 L 25.0 9.39 L 27.0 6.61 L 29.0 4.88 L 31.0 5.5 L 33.0 8.0 L 35.0 10.5 L 37.0 11.12 L 39.0 9.39 L 41.0 6.61 L 43.0 4.88 L 45.0 5.5 L 47.0 8.0 L 49.0 10.5 L 51.0 11.12 L 53.0 9.39 L 55.0 6.61 L 57.0 4.88 L 59.0 5.5 L 61.0 8.0 L 63.0 10.5 L 65.0 11.12 L 67.0 9.39 L 69.0 6.61 L 71.0 4.88 L 73.0 5.5 L 75.0 8.0 L 77.0 10.5 L 79.0 11.12 L 81.0 9.39 L 83.0 6.61 L 85.0 4.88 L 87.0 5.5 L 89.0 8.0 L 91.0 10.5 L 93.0 11.12 L 95.0 9.39 L 97.0 6.61 L 99.0 4.88 L 101.0 5.5 L 103.0 8.0 L 105.0 10.5 L 107.0 11.12 L 109.0 9.39 L 111.0 6.61 L 113.0 4.88 L 115.0 5.5' fill='none' stroke='%23a8823f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
  .tagline.unwritten { clip-path: inset(-15% 103% -15% -3%); }
  .tagline.unwritten.written { clip-path: inset(-15% -3% -15% -3%); }
  .home-social {
    margin-top: 52px;
    display: flex;
    justify-content: center;
    gap: 12px;
    align-items: center;
  }
  .home-social a {
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--soft);
    padding: 6px 14px;
    transition: color 0.25s ease;
  }
  .home-social a:hover { color: var(--gold); }
  .home-social .dot { color: var(--faint); font-size: 10px; }

  /* Resume & Contact shared column */
  .col {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 140px 28px 100px;
    box-sizing: border-box;
  }
  .page-title {
    font-family: var(--serif);
    font-size: 30px;
    font-weight: 400;
    margin: 0 0 40px;
  }
  .page-sub {
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0 0 18px;
  }

  .cv-group { margin-bottom: 56px; }
  /* the quill draws a thread down the experience margin */
  #score { position: relative; padding-left: 44px; }
  #about-thread { position: absolute; left: 0; top: 0; width: 36px; pointer-events: none; }
  #score.thread-on .cv-item {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  }
  #score.thread-on .cv-item.seen { opacity: 1; transform: none; }
  @media (prefers-reduced-motion: reduce) {
    #score.thread-on .cv-item { opacity: 1; transform: none; transition: none; }
  }
  .cv-item { padding: 20px 0; border-top: 1px solid var(--faint); }
  .cv-item:last-child { border-bottom: 1px solid var(--faint); }
  .cv-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    flex-wrap: wrap;
  }
  .cv-head .org { font-family: var(--serif); font-size: 17.5px; }
  .cv-head .yr {
    font-size: 12px;
    color: var(--soft);
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }
  .cv-role { font-size: 13px; letter-spacing: 0.04em; color: var(--gold); margin: 4px 0 0; }
  .cv-note { font-size: 14px; color: var(--soft); margin: 8px 0 0; line-height: 1.6; max-width: 36em; }
  .cv-note a { color: var(--ink); border-bottom: 1px solid var(--gold); }
  .cv-note a:hover { color: var(--gold); }


  /* Contact — the sealed letter */
  #page-contact { align-items: center; justify-content: center; text-align: center; padding: 100px 24px 80px; }
  .contact-inner { max-width: 560px; }
  .contact-title {
    font-family: var(--serif);
    font-size: clamp(34px, 6vw, 46px);
    font-weight: 400;
    margin: 0 0 46px;
  }
  .envelope {
    position: relative;
    width: min(86vw, 380px);
    aspect-ratio: 380 / 250;
    margin: 0 auto 22px;
    perspective: 900px;
  }
  .env-body {
    position: absolute; inset: 0; width: 100%; height: 100%;
    pointer-events: none;
    filter: drop-shadow(0 4px 26px rgba(42, 38, 32, 0.14));
  }
  .letter {
    position: absolute; left: 7%; right: 7%;
    top: 12%; bottom: 14%;
    background: linear-gradient(#fffdf8, #faf4e6);
    border: 1px solid var(--faint);
    border-radius: 3px;
    box-shadow: 0 1px 10px rgba(42, 38, 32, 0.08);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px;
    z-index: 2;
    opacity: 0;
    transform: translateY(16%);
    transition: transform 1s cubic-bezier(0.22, 1, 0.36, 1) 0.9s, opacity 0.6s ease 0.9s;
  }
  .envelope.open .letter { transform: translateY(-16%); opacity: 1; }
  .letter .mail {
    font-family: var(--serif); font-style: italic;
    font-size: clamp(17px, 4vw, 22px);
    color: var(--gold);
    border-bottom: 1px solid var(--gold);
    padding-bottom: 2px;
    cursor: pointer;
    background: none; border-top: none; border-left: none; border-right: none;
    transition: opacity 0.25s ease;
  }
  .letter .mail:hover { opacity: 0.7; }
  .letter .hint { font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--soft); }
  .flap {
    position: absolute; left: 0.5%; right: 0.5%; top: 0.5%;
    height: 64%;
    z-index: 3;
    clip-path: polygon(0 0, 100% 0, 51.2% 97%, 48.8% 97%);
    background: linear-gradient(#fbf6ea, #eadfc6);
    transform-origin: 50% 0;
    transition: transform 1s cubic-bezier(0.45, 0, 0.2, 1) 0.35s, opacity 0.28s ease 1.05s;
  }
  .flap::after {
    content: ""; position: absolute; inset: 0;
    clip-path: inherit;
    background: linear-gradient(rgba(42, 38, 32, 0) 55%, rgba(42, 38, 32, 0.09));
  }
  .envelope.open .flap { transform: rotateX(112deg); opacity: 0; }
  .seal {
    position: absolute; left: 50%; top: 62%;
    width: 104px; height: 104px;
    transform: translate(-50%, -50%);
    cursor: pointer;
    background: none; border: none; padding: 0;
    z-index: 5;
    filter: drop-shadow(0 3px 7px rgba(42, 38, 32, 0.28));
    transition: transform 0.35s ease, filter 0.35s ease;
  }
  @media (hover: hover) {
    .seal:hover {
      transform: translate(-50%, -50%) scale(1.04);
      filter: drop-shadow(0 5px 12px rgba(100, 37, 26, 0.5));
    }
    .envelope:hover + .invite { color: var(--gold); }
  }
  .seal:focus-visible { outline: 2px solid var(--gold); outline-offset: 6px; border-radius: 50%; }
  .seal-svg { width: 100%; height: 100%; display: block; }
  .envelope.open .seal {
    pointer-events: none;
    animation: popoff 0.85s cubic-bezier(0.5, 0, 0.8, 0.6) both;
  }
  @keyframes popoff {
    0% { transform: translate(-50%, -50%); opacity: 1; }
    18% { transform: translate(-50%, -52%) rotate(-3deg); }
    100% { transform: translate(-46%, 60%) rotate(16deg); opacity: 0; }
  }
  .invite {
    font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase;
    color: var(--soft); margin: 0 0 40px;
    transition: color 0.3s ease;
    min-height: 1.2em;
  }

  .voice {
    font-family: var(--serif); font-style: italic;
    font-size: 15px; color: var(--gold);
    min-height: 1.4em; margin: 0 0 30px;
    opacity: 0; transition: opacity 0.5s ease;
  }
  .voice.show { opacity: 1; }
  .contact-social { margin-top: 52px; display: flex; justify-content: center; gap: 12px; align-items: center; }
  .contact-social a {
    font-size: 11px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--soft);
    padding: 6px 14px;
    transition: color 0.25s ease;
  }
  .contact-social a:hover { color: var(--gold); }
  .contact-social .dot { color: var(--faint); font-size: 10px; }

  /* ————— The knight & the game ————— */
  .knight-wrap {
    position: relative;
    width: fit-content;
    margin: 0 auto 24px;
  }
  .knight-btn {
    appearance: none; background: none; border: none; cursor: pointer;
    display: block;
    position: relative;
    z-index: 1;
    margin: 0 auto;
    padding: 0;
    line-height: 0;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  }

  /* Ghost board: hovering the knight reveals the squares it could leap to */
  .knight-board {
    --kcell: clamp(58px, 9vw, 84px);
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%) scale(0.94);
    width: calc(var(--kcell) * 5);
    height: calc(var(--kcell) * 5);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent 100%);
    mask-image: radial-gradient(closest-side, #000 55%, transparent 100%);
  }
  .knight-btn:hover + .knight-board, .knight-btn.self-hover + .knight-board { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  .kb-cell { position: relative; }
  .kb-cell.dark { background: rgba(214, 196, 158, 0.32); }
  .kb-cell.kb-center { box-shadow: inset 0 0 0 1.5px rgba(168, 130, 63, 0.35); }
  .kb-cell.kb-move { background: rgba(168, 130, 63, 0.16); }
  .kb-cell.kb-move::after {
    content: "";
    position: absolute;
    top: 50%; left: 50%;
    width: 20%; height: 20%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(168, 130, 63, 0.5);
  }
  .home-inner.playing .knight-board { display: none; }
  .k-svg {
    display: block;
    width: clamp(84px, 13vw, 112px);
    height: auto;
    /* engraved ink, slightly faded into the cream like an old bookplate */
    color: rgba(74, 66, 52, 0.9);
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1), color 0.5s ease;
  }
  /* Hover: the knight lifts gently from the board — a slow levitation
     with its shadow left behind — while the quill signs beneath it. */
  .k-svg {
    filter: drop-shadow(0 0 0 rgba(42, 38, 32, 0));
    transition:
      width 0.6s cubic-bezier(0.22, 1, 0.36, 1),
      color 0.8s ease,
      transform 1.1s cubic-bezier(0.22, 1, 0.36, 1),
      filter 1.1s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .knight-btn:hover .k-svg, .knight-btn.agent-hover .k-svg, .knight-btn.self-hover .k-svg {
    color: var(--gold);
    transform: translateY(-12px) rotate(-3deg);
    filter: drop-shadow(0 18px 14px rgba(42, 38, 32, 0.18));
  }
  .knight-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 8px; border-radius: 8px; }
  .home-inner.playing .knight-btn { margin-bottom: 12px; }
  .home-inner.playing .k-svg { width: 34px; color: var(--gold); }
  .home-inner.playing .knight-btn:hover .k-svg, .knight-btn.agent-hover .k-svg, .knight-btn.self-hover .k-svg { transform: none; filter: none; }
  .home-inner.playing .knight-btn:hover { transform: rotate(4deg) scale(1.1); }
  @media (prefers-reduced-motion: reduce) {
    .knight-btn:hover .k-svg, .knight-btn.agent-hover .k-svg, .knight-btn.self-hover .k-svg { transform: none; filter: none; }
  }

  .knight-hint {
    display: none;
    font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
    color: var(--soft); margin: 14px 0 0;
  }
  @media (pointer: coarse) {
    .knight-hint { display: block; }
  }
  .home-inner.playing .knight-hint { display: none; }

  .home-text { transition: opacity 0.4s ease, transform 0.4s ease; }
  .home-inner.playing .home-text { opacity: 0; transform: translateY(28px); pointer-events: none; }
  .home-text[hidden] { display: none; }

  .chess-wrap { display: none; }
  .chess-wrap.open { display: block; animation: boardrise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }
  @keyframes boardrise {
    from { opacity: 0; transform: translateY(34px) scale(0.98); }
    to { opacity: 1; transform: none; }
  }

  .chess-status {
    font-family: var(--serif);
    font-style: italic;
    font-size: 17px;
    color: var(--gold);
    min-height: 1.5em;
    margin: 0 0 20px;
  }
  .board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    width: min(94vw, 520px);
    margin: 0 auto;
    border: 1px solid var(--faint);
    touch-action: manipulation;
    box-shadow: 0 2px 30px rgba(42, 38, 32, 0.08);
  }
  .sq {
    appearance: none; border: none; padding: 0; margin: 0;
    aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    font-size: clamp(34px, 10vw, 54px);
    line-height: 1;
    cursor: pointer;
    user-select: none;
    position: relative;
    font-family: var(--serif);
  }
  .sq.light { background: #efe8d6; }
  .sq.dark { background: #d6c49e; }
  .sq:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
  .sq { overflow: visible; }
  .sq .pc { width: 88%; height: 88%; display: block; pointer-events: none; will-change: transform; }
  .sq.sliding { z-index: 5; }
  .sq.last { box-shadow: inset 0 0 0 999px rgba(168, 130, 63, 0.14); }
  .sq.sel { box-shadow: inset 0 0 0 2px var(--gold); }
  .sq.chk { box-shadow: inset 0 0 0 3px rgba(146, 64, 44, 0.6); }
  .sq.hint::after {
    content: ""; position: absolute;
    width: 24%; height: 24%; border-radius: 50%;
    background: rgba(168, 130, 63, 0.45);
  }
  .sq.hintcap::after {
    content: ""; position: absolute; inset: 6%;
    border-radius: 50%; border: 2px solid rgba(168, 130, 63, 0.55);
  }
  .chess-controls { margin-top: 26px; display: flex; justify-content: center; gap: 26px; flex-wrap: wrap; }
  .chess-controls button {
    appearance: none; background: none; border: none; padding: 0; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    font-family: var(--sans);
    color: var(--soft);
    transition: color 0.25s ease;
  }
  .chess-controls .disc {
    width: 44px; height: 44px; border-radius: 50%;
    border: 1px solid var(--faint);
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.25s ease, background 0.25s ease;
  }
  .chess-controls svg { width: 17px; height: 17px; }
  .chess-controls .lbl { font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase; }
  .chess-controls button:hover { color: var(--gold); }
  .chess-controls button:hover .disc { border-color: var(--gold); }
  .chess-controls button:focus-visible { outline: none; }
  .chess-controls button:focus-visible .disc { outline: 2px solid var(--gold); outline-offset: 3px; }
  #btn-agent.on { color: var(--gold); }
  #btn-agent.on .disc { border-color: var(--gold); background: rgba(168, 130, 63, 0.12); }

  @media (max-width: 560px) {
    .chess-status { font-size: 14.5px; }
    .nav { padding: 18px 18px; }
    .nav .brand { font-size: 15px; }
    .nav .links { gap: 16px; }
    .nav .links a { letter-spacing: 0.12em; font-size: 11px; }
    .envelope { width: min(92vw, 380px); }
    .chess-controls { gap: 20px; }
  }
  @media (prefers-reduced-motion: reduce) {
    .page.visible { animation: none; }
    .letter, .flap { transition-duration: 0.01s !important; transition-delay: 0s !important; }
    .envelope.open .seal { animation-duration: 0.01s; }
  }

  /* ————— the daily mate ————— */
  .puzzle-col {
    width: 100%;
    max-width: 620px;
    margin: 0 auto;
    padding: 130px 24px 90px;
    box-sizing: border-box;
    text-align: center;
  }
  #page-puzzle { justify-content: center; }
  .puzzle-col .page-title { margin-bottom: 6px; }
  .puzzle-col .page-sub { margin-bottom: 26px; }
  .puzzle-link {
    display: inline-block;
    margin-top: 20px;
    font-family: var(--serif); font-style: italic;
    font-size: 13.5px;
    color: var(--soft);
    border-bottom: 1px solid transparent;
    transition: color 0.25s ease, border-color 0.25s ease;
  }
  .puzzle-link:hover { color: var(--gold); border-color: var(--gold); }
  .puzzle-link.beckon { color: var(--gold); }

  /* ————— off the board (404) ————— */
  #page-404 { align-items: center; justify-content: center; text-align: center; padding: 100px 24px; }
  .nf-inner { max-width: 480px; }
  .nf-title {
    font-family: var(--serif);
    font-size: clamp(34px, 6vw, 46px);
    font-weight: 400;
    margin: 0 0 14px;
  }
  .nf-voice {
    font-family: var(--serif); font-style: italic;
    font-size: 16px; color: var(--gold);
    margin: 0 0 10px;
  }
