/* Fidelity layer: the accepted M foldout and J2 reader are the layout authority. */

:root {
  --font-field-display: "Bahnschrift Condensed", "Arial Narrow", "Aptos Narrow", sans-serif;
  --field-gutter: clamp(2rem, 4vw, 4rem);
}

h1[tabindex="-1"],
h2[tabindex="-1"] {
  outline: none;
}

.identity-copy h1,
.fold-heading h2,
.fold-title,
.reader-home,
.page-header h2,
.project-sheet-list strong,
.resume-entry h4,
.contact-links strong {
  font-family: var(--font-field-display);
  font-stretch: condensed;
}

@media (min-width: 801px) {
  .foldout-view {
    align-content: center;
    padding: 1.4rem 2rem 1rem;
  }

  .foldout {
    width: min(100%, 1180px);
    min-height: 610px;
    height: min(78svh, 720px);
    max-height: 720px;
    margin-block: auto;
  }

  .identity-panel {
    flex-basis: clamp(220px, 20vw, 260px);
    padding: 2.4rem 2rem;
  }

  .identity-copy h1 {
    max-width: 5ch;
    font-size: clamp(3.45rem, 4.25vw, 4.8rem);
    font-weight: 650;
    letter-spacing: -0.045em;
    line-height: 0.78;
  }

  .identity-role {
    margin-top: 1.7rem;
    font-size: 0.62rem;
  }

  .identity-summary {
    max-width: 15rem;
    margin-top: 1.25rem;
    font-size: 0.78rem;
    line-height: 1.55;
  }

  .identity-actions {
    gap: 1.15rem;
  }

  .fold-panel {
    flex-basis: clamp(58px, 5vw, 72px);
  }

  .fold-panel.is-open .fold-trigger {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }

  .fold-panel:not(.is-open) .fold-trigger {
    padding: 1.45rem 0.95rem;
  }

  .fold-panel:not(.is-open) .fold-title {
    font-size: clamp(1.2rem, 1.7vw, 1.65rem);
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  .fold-body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-width: 0;
    width: 100%;
    padding: clamp(2.7rem, 5.5vh, 4.2rem) clamp(2.7rem, 4.6vw, 4.7rem) 2.5rem;
  }

  .fold-heading {
    max-width: 46rem;
  }

  .section-label {
    margin-bottom: 1rem;
    font-size: 0.61rem;
  }

  .fold-heading h2 {
    max-width: 9ch;
    font-size: clamp(4rem, 5.8vw, 6.25rem);
    font-weight: 650;
    letter-spacing: -0.045em;
    line-height: 0.82;
  }

  .fold-heading > p:last-child {
    max-width: 35rem;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .home-projects {
    align-self: end;
    margin: 2rem 0 1.3rem;
  }

  .home-project-item {
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    min-height: 48px;
    padding: 0.65rem 0;
  }

  .home-projects strong {
    font-family: var(--font-field-display);
    font-size: clamp(1.05rem, 1.45vw, 1.35rem);
    font-weight: 600;
    letter-spacing: -0.015em;
  }

  .home-projects small {
    font-size: 0.52rem;
  }

  .panel-link {
    font-size: 0.61rem;
  }

  .home-footer {
    width: min(100%, 1180px);
  }

  .reader-view {
    grid-template-columns:
      clamp(190px, 16vw, 230px)
      minmax(0, 1fr)
      repeat(4, clamp(42px, 3.55vw, 54px));
  }

  .reader-identity {
    padding: 2.4rem 2rem;
  }

  .reader-home {
    font-size: clamp(3.2rem, 4.1vw, 4.6rem);
    font-weight: 650;
    letter-spacing: -0.055em;
    line-height: 0.75;
  }

  .reader-page {
    width: 100%;
    max-width: none;
    padding: clamp(2.7rem, 4.6vw, 4.6rem) var(--field-gutter) 6rem;
  }

  .project-page {
    padding-bottom: 7rem;
  }

  .project-page .page-header {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(220px, 0.65fr);
    grid-template-areas:
      "index index"
      "title summary"
      "title link";
    gap: 0.8rem clamp(2.5rem, 5vw, 5rem);
    align-items: start;
    min-height: 118px;
    padding: 0 0 1.5rem;
    border-bottom: 0;
  }

  .project-page .page-index {
    grid-area: index;
    font-size: 0.61rem;
  }

  .project-page .page-header h2 {
    grid-area: title;
    align-self: start;
    max-width: 18ch;
    font-size: clamp(2.05rem, 3vw, 3.2rem);
    font-weight: 550;
    letter-spacing: -0.025em;
    line-height: 0.9;
  }

  .project-page .page-header > p:last-of-type {
    grid-area: summary;
    max-width: 27rem;
    font-size: 0.78rem;
    line-height: 1.55;
  }

  .project-page .page-header .external-link {
    grid-area: link;
    align-self: end;
    margin: 0;
    font-size: 0.56rem;
  }

  .project-art {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    width: 100%;
    height: clamp(430px, 61svh, 620px);
    margin: 0;
    padding: clamp(1.4rem, 2.8vw, 2.7rem);
    overflow: hidden;
    border: 1px solid rgba(233, 227, 215, 0.18);
    background-size: 420px 420px;
  }

  .project-art-paper {
    background-color: #1b1f1c;
    color: var(--paper);
  }

  .project-art img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain;
  }

  .project-art figcaption {
    display: grid;
    grid-template-columns: 4.2rem minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    margin: 0;
    padding-top: 1rem;
    font-size: 0.57rem;
    line-height: 1.55;
    text-transform: none;
  }

  .project-art figcaption::before {
    content: "TOOLS";
    color: var(--cyan);
    font-weight: 700;
  }

  .content-grid {
    margin-top: 4rem;
  }

  .content-grid section {
    min-height: 230px;
  }

  .reader-spines a {
    padding: 1.35rem 0.55rem;
  }

  .reader-spines a strong {
    font-family: var(--font-field-display);
    font-size: 1rem;
    font-weight: 600;
  }

  .reader-page:not(.project-page) .page-header h2 {
    font-size: clamp(4.2rem, 6.2vw, 6.8rem);
    line-height: 0.82;
  }
}

@media (max-width: 800px) {
  .foldout-view,
  .foldout {
    min-height: 100svh;
  }

  .identity-panel {
    position: sticky;
    top: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 58px;
    height: 58px;
    padding: 0 1.1rem;
    border-bottom: 1px solid rgba(233, 227, 215, 0.28);
  }

  .identity-mark,
  .identity-role,
  .identity-summary {
    display: none;
  }

  .identity-copy {
    display: flex;
    align-items: center;
  }

  .identity-copy h1 {
    max-width: none;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1;
    white-space: nowrap;
  }

  .identity-actions {
    flex-wrap: nowrap;
    gap: 0.85rem;
  }

  .identity-actions a,
  .identity-actions .theme-toggle {
    font-size: 0.55rem;
  }

  .fold-panel,
  .fold-panel.is-open {
    grid-template-rows: 54px 0fr;
    min-height: 54px;
  }

  .fold-panel.is-open {
    grid-template-rows: 0 1fr;
  }

  .fold-trigger,
  .fold-panel:not(.is-open) .fold-trigger,
  .fold-panel.is-open .fold-trigger {
    padding: 0.7rem 1.05rem;
  }

  .fold-title,
  .fold-panel:not(.is-open) .fold-title {
    font-family: var(--font-field-display);
    font-size: 1.35rem;
    font-weight: 600;
  }

  .fold-body {
    min-height: calc(100svh - 58px);
    padding: 2.4rem 1.25rem 2rem;
  }

  .section-label {
    margin-bottom: 1rem;
    font-size: 0.57rem;
  }

  .fold-heading h2 {
    max-width: 8ch;
    font-size: clamp(3.7rem, 16vw, 5.4rem);
    font-weight: 650;
    letter-spacing: -0.045em;
    line-height: 0.82;
  }

  .fold-heading > p:last-child {
    margin-top: 1.4rem;
    font-size: 0.88rem;
    line-height: 1.55;
  }

  .home-projects {
    margin-top: 2.4rem;
  }

  .home-project-item {
    min-height: 54px;
  }

  .home-projects strong {
    font-family: var(--font-field-display);
    font-size: 1.15rem;
    font-weight: 600;
  }

  .reader-mobile-header {
    height: 56px;
    padding: 0 1rem;
  }

  .reader-stage {
    padding-bottom: 58px;
  }

  .reader-page {
    min-height: calc(100svh - 114px);
    padding: 2rem 1.15rem 4rem;
  }

  .project-page .page-header {
    padding-bottom: 1.4rem;
  }

  .project-page .page-header h2 {
    max-width: 18ch;
    margin-top: 1.4rem;
    font-size: clamp(1.9rem, 9vw, 2.85rem);
    font-weight: 550;
    letter-spacing: -0.025em;
    line-height: 0.9;
  }

  .project-page .page-header > p:last-of-type {
    max-width: 32rem;
    margin-top: 1.25rem;
    font-size: 0.78rem;
    line-height: 1.55;
  }

  .project-page .page-header .external-link {
    margin-top: 1.3rem;
    font-size: 0.55rem;
  }

  .project-art {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    height: min(54svh, 470px);
    margin: 0;
    padding: 0.9rem;
    overflow: hidden;
    border: 1px solid rgba(233, 227, 215, 0.2);
  }

  .project-art-paper {
    background-color: #1b1f1c;
    color: var(--paper);
  }

  .project-art img {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain;
  }

  .project-art figcaption {
    display: grid;
    grid-template-columns: 3.4rem minmax(0, 1fr);
    gap: 0.7rem;
    margin: 0;
    padding-top: 0.8rem;
    font-size: 0.49rem;
    line-height: 1.5;
  }

  .project-art figcaption::before {
    content: "TOOLS";
    color: var(--cyan);
    font-weight: 700;
  }

  .content-grid {
    margin-top: 2.5rem;
  }

  .reader-spines a {
    height: 58px;
    padding: 0.55rem 0.2rem;
  }

  .reader-spines a strong {
    font-family: var(--font-field-display);
    font-size: 0.72rem;
    font-weight: 600;
  }
}

@media (max-width: 420px) {
  .identity-actions a {
    display: none;
  }

  .fold-heading h2 {
    font-size: clamp(3.3rem, 15.5vw, 4.8rem);
  }

  .project-page .page-header h2 {
    font-size: clamp(1.8rem, 8.7vw, 2.5rem);
  }
}

@media (max-width: 800px) {
  .fold-panel.is-open .fold-trigger {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }

  .project-page .page-header > p:last-of-type {
    display: none;
  }
}

@media (max-width: 800px) {
  .fold-panel.is-open .fold-trigger {
    position: static;
    display: block;
    width: 100%;
    height: 0;
  }
}



/* Production refinement: larger canvas, contained identity, and reversible folds. */
@media (min-width: 801px) {
  .foldout-view {
    align-content: stretch;
    padding: clamp(1.25rem, 2.4vw, 3rem) clamp(1.25rem, 3vw, 4rem) 1.15rem;
  }

  .foldout {
    width: min(100%, 1600px);
    min-height: min(620px, calc(100svh - 6.5rem));
    height: calc(100svh - clamp(5.5rem, 8vw, 7rem));
    max-height: 900px;
  }

  .identity-panel {
    flex-basis: clamp(270px, 19vw, 320px);
    overflow: hidden;
    padding: clamp(2.25rem, 3vw, 3.25rem) clamp(1.75rem, 2.2vw, 2.5rem);
    transition: flex-basis 620ms var(--ease-material);
  }

  .foldout:not(.has-open-fold) .identity-panel {
    flex: 1 1 auto;
  }

  .foldout:not(.has-open-fold) .identity-copy {
    max-width: 46rem;
  }

  .foldout:not(.has-open-fold) .identity-copy h1 {
    max-width: 7ch;
    font-size: clamp(5rem, 7vw, 8rem);
  }

  .foldout:not(.has-open-fold) .identity-summary {
    max-width: 30rem;
    font-size: 1rem;
  }

  .identity-copy h1 {
    max-width: 100%;
    font-size: clamp(3.4rem, 3.65vw, 4.45rem);
    line-height: 0.8;
  }

  .identity-summary {
    max-width: 17rem;
    font-size: 0.84rem;
  }

  .fold-panel {
    flex-basis: clamp(62px, 4.6vw, 76px);
  }

  .fold-panel.is-open .fold-trigger {
    position: absolute;
    z-index: 4;
    top: 1.25rem;
    right: 1.25rem;
    left: auto;
    display: flex;
    gap: 0.65rem;
    align-items: center;
    width: auto;
    height: auto;
    padding: 0.7rem 0.85rem;
    overflow: visible;
    border: 1px solid currentColor;
    background: color-mix(in srgb, currentColor 8%, transparent);
    opacity: 1;
    pointer-events: auto;
    writing-mode: horizontal-tb;
  }

  .fold-panel.is-open .fold-trigger::after {
    content: "Close";
    font: 600 0.52rem/1 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .fold-panel.is-open .fold-title {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
  }

  .fold-body {
    padding: clamp(4.6rem, 7vh, 6rem) clamp(2.8rem, 4.4vw, 5rem) 2.75rem;
  }

  .fold-heading h2 {
    font-size: clamp(4.15rem, 5.3vw, 6.8rem);
  }

  .home-footer {
    width: min(100%, 1600px);
    margin-top: 0.9rem;
    font-size: 0.68rem;
    letter-spacing: 0.025em;
    text-transform: none;
  }

  .footer-label {
    color: var(--cyan);
    font-weight: 700;
  }
}

@media (max-width: 800px) {
  .identity-panel {
    overflow: hidden;
  }

  .fold-panel.is-open {
    grid-template-rows: 54px 1fr;
  }

  .fold-panel.is-open .fold-trigger {
    position: relative;
    z-index: 2;
    display: flex;
    width: 100%;
    height: 54px;
    padding: 0.7rem 1.05rem;
    overflow: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .fold-panel.is-open .fold-trigger::after {
    content: "Close";
    margin-left: auto;
    font: 600 0.52rem/1 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .fold-body {
    min-height: calc(100svh - 112px);
  }
}

/* Collapsed profile becomes the desktop focal point. */
@media (min-width: 801px) {
  .foldout.is-profile .identity-panel {
    flex: 1 1 auto;
  }

  .foldout.is-profile .identity-copy {
    max-width: 46rem;
  }

  .foldout.is-profile .identity-copy h1 {
    max-width: 7ch;
    font-size: clamp(5rem, 7vw, 8rem);
  }

  .foldout.is-profile .identity-summary {
    max-width: 30rem;
    font-size: 1rem;
  }
}

/* Mobile close returns to the developer profile, not an empty field. */
@media (max-width: 800px) {
  .foldout.is-profile .identity-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 260px;
    height: auto;
    padding: 1.4rem 1.1rem;
  }

  .foldout.is-profile .identity-mark,
  .foldout.is-profile .identity-role,
  .foldout.is-profile .identity-summary {
    display: block;
  }

  .foldout.is-profile .identity-copy {
    display: block;
    margin-top: 2.8rem;
  }

  .foldout.is-profile .identity-copy h1 {
    font-size: clamp(2.8rem, 14vw, 4.6rem);
    white-space: normal;
  }

  .foldout.is-profile .identity-role {
    margin-top: 1.25rem;
    font-size: 0.58rem;
  }

  .foldout.is-profile .identity-summary {
    max-width: 24rem;
    margin-top: 1rem;
    font-size: 0.8rem;
  }

  .foldout.is-profile .identity-actions {
    margin-top: 2rem;
  }
}
