@font-face {
  font-family: "Press Start 2P";
  src: url("../fonts/PressStart2P-Regular.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #173f3b;
  --ink-soft: #4c6762;
  --paper: #f3ead6;
  --paper-light: #fffaf0;
  --coral: #e96f57;
  --mustard: #e6ab36;
  --teal: #2f7770;
  --plum: #7f4b6a;
  --line: rgba(23, 63, 59, .18);
  --shadow: 0 18px 50px rgba(23, 63, 59, .13);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 15%, rgba(233,111,87,.13), transparent 24rem),
    radial-gradient(circle at 92% 42%, rgba(47,119,112,.12), transparent 28rem),
    var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.55;
}
a { color: inherit; }
.skip-link { position: fixed; z-index: 99; top: .75rem; left: .75rem; padding: .75rem 1rem; color: white; background: var(--ink); border-radius: 999px; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.site-header, footer { width: min(1180px, calc(100% - 2rem)); margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; }
.site-header { min-height: 88px; }
.brand { display: inline-flex; align-items: center; gap: .7rem; font-weight: 700; text-decoration: none; }
.brand-mark { display: grid; width: 2.4rem; aspect-ratio: 1; place-items: center; border-radius: 50% 48% 52% 46%; color: var(--paper-light); background: var(--coral); box-shadow: inset -4px -5px 0 rgba(23,63,59,.12); font-family: "Press Start 2P", system-ui, sans-serif; font-size: .75rem; }
.home-link { min-height: 44px; display: inline-flex; align-items: center; gap: .4rem; font-size: .92rem; font-weight: 700; text-underline-offset: .3rem; }
main { overflow: hidden; }

.hero { width: min(1180px, calc(100% - 2rem)); min-height: calc(100vh - 88px); margin-inline: auto; padding: clamp(2rem, 6vw, 6rem) 0; display: grid; grid-template-columns: .82fr 1.18fr; align-items: center; gap: clamp(2rem, 6vw, 5.5rem); }
.eyebrow { margin: 0 0 .75rem; color: var(--coral); font-family: "Press Start 2P", system-ui, sans-serif; font-size: clamp(.57rem, 1vw, .7rem); line-height: 1.7; letter-spacing: .03em; text-transform: uppercase; }
h1, h2, h3, h4, p { text-wrap: pretty; }
h1, h2 { margin: 0; font-weight: 500; line-height: .98; letter-spacing: -.045em; }
h1 { font-size: clamp(3.3rem, 7.8vw, 7.5rem); }
h1 em, .family-note em { color: var(--teal); font-weight: 400; }
h2 { font-size: clamp(2.65rem, 5.3vw, 5.2rem); }
.intro { max-width: 36rem; margin: 1.7rem 0 2rem; color: var(--ink-soft); font-size: clamp(1.1rem, 1.8vw, 1.35rem); }
.primary-link { display: inline-flex; min-height: 52px; align-items: center; gap: 1rem; padding: .8rem 1.15rem; border: 1px solid var(--ink); border-radius: 999px; font-weight: 700; text-decoration: none; transition: transform .2s ease, background .2s ease, color .2s ease; }
.primary-link:hover, .primary-link:focus-visible { color: var(--paper-light); background: var(--ink); transform: translateY(-2px); }
.hero-art { position: relative; margin: 0; transform: rotate(1.6deg); }
.hero-art::before { content: ""; position: absolute; z-index: -1; inset: -1rem 1.5rem 1rem -1.5rem; border: 2px solid var(--coral); border-radius: 3rem 1.2rem 3.5rem 1.5rem; transform: rotate(-4deg); }
.hero-art img { display: block; width: 100%; height: auto; border: 10px solid var(--paper-light); border-radius: 1.2rem 2.4rem 1.35rem 3rem; box-shadow: var(--shadow); }
.hero-art figcaption { position: absolute; right: 1.2rem; bottom: -1.2rem; max-width: 15rem; padding: .7rem 1rem; background: var(--mustard); font-size: .78rem; font-style: italic; transform: rotate(-2deg); }

.tree-section { padding: clamp(5rem, 11vw, 10rem) max(1rem, calc((100vw - 1180px) / 2)); background: var(--paper-light); }
.section-heading { display: grid; grid-template-columns: 1.2fr .8fr; align-items: end; gap: 2rem; margin-bottom: 4rem; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 1.2rem; color: var(--ink-soft); font-size: .86rem; }
.legend span { display: inline-flex; align-items: center; gap: .45rem; }
.line { display: block; width: 2.4rem; border-top: 3px solid var(--teal); }
.line.love { border-top-color: var(--coral); border-top-style: dashed; }
.line.friend { border-top-color: var(--plum); border-top-style: dotted; }
.sound-guide { display: flex; align-items: center; justify-content: space-between; gap: 1.2rem; max-width: 780px; margin: -1.7rem auto 3.5rem; padding: .8rem .9rem; border: 1px solid rgba(230,171,54,.55); border-radius: 1rem; background: rgba(230,171,54,.13); }
.sound-guide > div { display: flex; align-items: center; gap: .8rem; }
.sound-guide p { margin: 0; color: var(--ink-soft); font-size: .9rem; line-height: 1.35; }
.sound-guide strong { color: var(--ink); }
.sound-symbol { display: grid; width: 2.7rem; height: 2.7rem; min-width: 2.7rem; min-height: 2.7rem; padding: 0; box-sizing: border-box; flex: 0 0 auto; place-items: center; border-radius: 50%; color: white; background: var(--coral); font-size: 1.2rem; line-height: 1; }
#sound-toggle { min-height: 44px; padding: .6rem 1rem; border: 1px solid var(--ink); border-radius: 999px; color: white; background: var(--ink); font: 700 .82rem Georgia, serif; cursor: pointer; white-space: nowrap; }
#sound-toggle[aria-pressed="false"] { color: var(--ink); background: transparent; }
#sound-toggle:disabled { cursor: not-allowed; opacity: .55; }
.mobile-view-switch { display: none; }
.tree-groups { display: grid; gap: 3rem; }
.family-tree { position: relative; padding: clamp(1.4rem, 4vw, 3rem); border: 1px solid var(--line); background: #fbf5e9; border-radius: 2rem .6rem 2.6rem .8rem; }
.family-tree::before { content: ""; position: absolute; inset: .65rem; pointer-events: none; border: 1px solid rgba(233,111,87,.2); border-radius: 1.2rem .4rem 2rem .6rem; }
.tree-label { position: relative; z-index: 2; margin-bottom: 3rem; text-align: center; }
.tree-label h3 { margin: 0; font-size: clamp(2rem, 4vw, 3.5rem); font-weight: 500; letter-spacing: -.04em; }
.tree-label > p:last-child { margin: .5rem 0 0; color: var(--ink-soft); }

.parents { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1.2rem; max-width: 760px; margin: 0 auto; }
.relation-badge { position: relative; z-index: 4; display: inline-block; justify-self: center; padding: .38rem .7rem; color: white; background: var(--teal); border-radius: 999px; font-family: "Press Start 2P", system-ui, sans-serif; font-size: .5rem; line-height: 1.4; white-space: nowrap; }
.parents::before { content: ""; position: absolute; top: 50%; left: 28%; right: 28%; border-top: 3px solid var(--teal); }
.descent { position: relative; width: 3px; height: 68px; margin: 0 auto; background: var(--teal); }
.descent::before { content: ""; position: absolute; left: 50%; top: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--teal); transform: translate(-50%, -50%); }
.child-row { max-width: 360px; margin: 0 auto; }

.person-card { position: relative; z-index: 2; min-width: 0; display: grid; grid-template-columns: 42% 58%; min-height: 180px; overflow: hidden; border: 1px solid var(--line); border-radius: .8rem 1.8rem .8rem 1.5rem; background: var(--paper-light); box-shadow: 0 10px 30px rgba(23,63,59,.08); }
.person-card.featured { border: 3px solid var(--mustard); transform: rotate(-1deg); }
.portrait { min-height: 100%; padding: 0; border: 0; border-radius: 0; background-color: var(--paper); background-image: url("assets/dalfolk-portratt-v2.jpg"); background-repeat: no-repeat; background-size: 400% 300%; background-position: var(--x) var(--y); filter: saturate(.94) contrast(.97); }
.portrait.has-square-portrait { background-size: cover; background-position: center; }
.speak-button { position: relative; cursor: pointer; appearance: none; }
.speak-button::after { content: "♪"; position: absolute; right: .55rem; bottom: .55rem; display: grid; width: 2rem; height: 2rem; min-width: 2rem; min-height: 2rem; padding: 0; box-sizing: border-box; place-items: center; border: 2px solid rgba(255,255,255,.9); border-radius: 50%; color: white; background: rgba(23,63,59,.78); box-shadow: 0 2px 8px rgba(23,63,59,.25); font: 700 .85rem/1 Georgia, serif; transition: transform .2s ease, background .2s ease; }
.speak-button:hover::after, .speak-button:focus-visible::after, .speak-button.is-speaking::after { background: var(--coral); transform: scale(1.14); }
.speak-button.is-speaking { animation: speaking-pulse 1s ease-in-out infinite; }
@keyframes speaking-pulse { 50% { filter: saturate(1.15) brightness(1.04); } }
.person-card > div:last-child, .friend-card > div:last-child { min-width: 0; align-self: center; padding: 1rem; }
.person-card span, .friend-card span, .ancestor-card span:not(.ancestor-icon) { color: var(--plum); font-family: "Press Start 2P", system-ui, sans-serif; font-size: .48rem; line-height: 1.5; text-transform: uppercase; }
.person-card h4, .friend-card h3, .ancestor-card h4 { max-width: 100%; margin: .35rem 0; font-size: clamp(1.2rem, 2.1vw, 2rem); line-height: 1.08; overflow-wrap: anywhere; hyphens: auto; }
.person-card p, .friend-card p, .ancestor-card p { margin: 0; color: var(--ink-soft); font-size: .86rem; line-height: 1.35; }
.info-speak-trigger { border-radius: .25rem; cursor: pointer; transition: color .2s ease, background .2s ease; }
.info-speak-trigger:hover, .info-speak-trigger:focus-visible, .info-speak-trigger.is-speaking { color: var(--ink); background: rgba(230,171,54,.12); }
.info-speak-button { min-height: 40px; margin-top: .85rem; padding: .48rem .7rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: transparent; font: 700 .78rem Georgia, serif; cursor: pointer; }
.info-speak-button::before { content: "▶"; margin-right: .35rem; color: var(--coral); font-size: .65rem; }
.info-speak-button:hover, .info-speak-button:focus-visible, .info-speak-button.is-speaking { color: white; background: var(--ink); border-color: var(--ink); }

.affection-branch { position: relative; display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 1rem; max-width: 1050px; margin: 3.5rem auto 0; }
.affection-branch::before { content: ""; position: absolute; top: 50%; left: 10%; right: 10%; border-top: 3px dashed var(--coral); }
.affection-branch .person-card:first-of-type { grid-column: 3; }
.affection-branch .person-card:last-of-type { grid-column: 5; }
.likes { grid-column: 2; color: var(--ink); background: var(--mustard); }
.siblings { grid-column: 4; background: var(--teal); }

.ancestor-card { position: relative; z-index: 2; max-width: 360px; min-height: 130px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 50% 44% 48% 42%; background: var(--paper-light); text-align: center; justify-content: center; }
.ancestor-icon { display: grid; width: 3.5rem; aspect-ratio: 1; flex: 0 0 auto; place-items: center; border-radius: 50%; color: white; background: var(--coral); font-size: 1.4rem; }
.sibling-branch { position: relative; width: 68%; height: 72px; margin: 0 auto; border-top: 3px solid var(--teal); transform: translateY(68px); }
.sibling-branch::before { content: ""; position: absolute; left: 50%; bottom: 100%; width: 3px; height: 70px; background: var(--teal); }
.sibling-branch i { position: absolute; top: 0; width: 3px; height: 70px; background: var(--teal); }
.sibling-branch i:nth-child(1) { left: 0; }
.sibling-branch i:nth-child(2) { left: 50%; }
.sibling-branch i:nth-child(3) { right: 0; }
.branch-note { position: relative; z-index: 3; width: max-content; margin: 2.6rem auto 1.3rem; padding: .35rem .65rem; color: white; background: var(--teal); border-radius: 999px; font-family: "Press Start 2P", system-ui, sans-serif; font-size: .48rem; }
.siblings-row { position: relative; z-index: 2; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }

.friends-section { padding: clamp(5rem, 10vw, 9rem) max(1rem, calc((100vw - 1180px) / 2)); }
.section-heading.compact { align-items: end; }
.section-heading.compact > p { max-width: 30rem; margin: 0 0 .5rem auto; color: var(--ink-soft); }
.friends-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.friend-card { min-width: 0; background: var(--paper-light); overflow: hidden; }
.friend-card .portrait { aspect-ratio: 1 / 1.05; }
.friend-card > div:last-child { min-height: 145px; }

.residents-section { padding: clamp(5rem, 10vw, 9rem) max(1rem, calc((100vw - 1180px) / 2)); background: var(--paper-light); }
.residents-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); background: var(--line); }
.resident-card { min-width: 0; background: #fbf5e9; overflow: hidden; }
.resident-portrait { display: block; width: 100%; min-height: 0; aspect-ratio: 1 / 1; background-size: 300% 300%; }
.resident-portrait.sheet-a { background-image: url("assets/dalfolk-portratt-ark-a.jpg"); }
.resident-portrait.sheet-b { background-image: url("assets/dalfolk-portratt-ark-b.jpg"); }
.resident-card > div { min-width: 0; min-height: 150px; padding: 1.15rem; }
.resident-card span { color: var(--plum); font-family: "Press Start 2P", system-ui, sans-serif; font-size: .48rem; line-height: 1.5; text-transform: uppercase; }
.resident-card h3 { max-width: 100%; margin: .42rem 0; font-size: clamp(1.25rem, 2.35vw, 2.2rem); line-height: 1.08; overflow-wrap: anywhere; hyphens: auto; }
.resident-card p { margin: 0; color: var(--ink-soft); font-size: .92rem; }

.family-note { width: min(880px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(6rem, 13vw, 11rem) 0; text-align: center; }
.family-note::before { content: "✦"; display: block; margin-bottom: 1rem; color: var(--mustard); font-size: 2rem; }
.family-note > p:last-child { max-width: 40rem; margin: 2rem auto 0; color: var(--ink-soft); font-size: 1.1rem; }
footer { padding: 2rem 0 3rem; border-top: 1px solid var(--line); font-size: .82rem; }
footer p { max-width: 39rem; margin: 0; color: var(--ink-soft); }
footer > a:last-child { min-height: 44px; display: inline-flex; align-items: center; white-space: nowrap; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 4px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero-copy { max-width: 48rem; }
  .hero-art { width: min(780px, 94%); margin-inline: auto; }
  .friends-grid { grid-template-columns: repeat(2, 1fr); }
  .residents-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .affection-branch { grid-template-columns: 1fr; max-width: 520px; }
  .affection-branch::before { top: 8%; bottom: 8%; left: 50%; right: auto; border-top: 0; border-left: 3px dashed var(--coral); }
  .affection-branch .person-card:first-of-type, .affection-branch .person-card:last-of-type, .likes, .siblings { grid-column: 1; }
  .likes { grid-row: 1; }
  .affection-branch .person-card:first-of-type { grid-row: 2; }
  .siblings { grid-row: 3; }
  .affection-branch .person-card:last-of-type { grid-row: 4; }
}

@media (max-width: 1100px) {
  html, body { touch-action: pan-y; }
  body { font-size: 16px; }
  body, body * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .site-header { min-height: 72px; }
  .home-link { font-size: 0; }
  .home-link::before { content: "Hem"; font-size: .9rem; }
  .hero { min-height: calc(100svh - 72px); align-content: center; padding: 2.2rem 0 4.7rem; }
  h1 { font-size: clamp(3rem, 15vw, 5rem); }
  .hero-art { width: 100%; }
  .hero-art img { border-width: 6px; }
  .hero-art figcaption { right: .5rem; bottom: -2rem; }
  .section-heading { grid-template-columns: 1fr; margin-bottom: 2.5rem; }
  .legend { justify-content: flex-start; }
  .sound-guide { align-items: stretch; margin-top: 0; flex-direction: column; }
  #sound-toggle { align-self: flex-start; }
  .mobile-view-switch { position: sticky; z-index: 20; top: .5rem; display: flex; align-items: center; gap: .35rem; width: fit-content; margin: -1.5rem auto 2rem; padding: .35rem; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,250,240,.94); box-shadow: 0 8px 24px rgba(23,63,59,.12); backdrop-filter: blur(8px); }
  .mobile-view-switch > span { padding: 0 .45rem; color: var(--ink-soft); font-size: .72rem; font-weight: 700; }
  .mobile-view-switch button { min-height: 40px; padding: .45rem .7rem; border: 0; border-radius: 999px; color: var(--ink); background: transparent; font: 700 .76rem Georgia, serif; cursor: pointer; }
  .mobile-view-switch button.is-active { color: white; background: var(--ink); }
  .tree-section { padding-inline: .35rem; }
  .family-tree { padding: 2rem .55rem; }
  .parents { grid-template-columns: 1fr; width: 100%; max-width: none; }
  .parents::before { top: 10%; bottom: 10%; left: 50%; right: auto; border-top: 0; border-left: 3px solid var(--teal); }
  .couple { grid-row: 2; }
  .descent { height: 46px; }
  .child-row { width: 100%; max-width: none; }
  .ancestor-card { width: 100%; max-width: none; }
  .siblings-row { grid-template-columns: 1fr; width: 100%; max-width: none; margin: 0 auto; }
  .sibling-branch { width: 3px; height: 60px; border: 0; background: var(--teal); transform: none; }
  .sibling-branch::before, .sibling-branch i { display: none; }
  .branch-note { margin-top: -1.1rem; }
  .affection-branch { width: 100%; max-width: none; }
  .person-card { min-height: 175px; }
  .portrait.has-square-portrait { background-size: contain; background-color: var(--paper-light); }
  .friends-grid { grid-template-columns: 1fr; }
  .friend-card { display: grid; grid-template-columns: 44% 56%; }
  .friend-card .portrait { aspect-ratio: auto; min-height: 220px; }
  .residents-grid { grid-template-columns: 1fr; }
  .resident-card { display: grid; grid-template-columns: 44% 56%; }
  .resident-portrait { min-height: 225px; aspect-ratio: auto; }
  .resident-card > div { align-self: center; min-height: 0; padding: 1rem; }
  body[data-mobile-layout="stacked"] .person-card,
  body[data-mobile-layout="stacked"] .friend-card,
  body[data-mobile-layout="stacked"] .resident-card { display: grid; grid-template-columns: 1fr; min-height: 0; }
  body[data-mobile-layout="stacked"] .person-card .portrait,
  body[data-mobile-layout="stacked"] .friend-card .portrait,
  body[data-mobile-layout="stacked"] .resident-card .portrait { display: block; width: 100%; min-height: 0; aspect-ratio: 1 / 1; }
  body[data-mobile-layout="stacked"] .person-card > div:last-child,
  body[data-mobile-layout="stacked"] .friend-card > div:last-child,
  body[data-mobile-layout="stacked"] .resident-card > div { width: 100%; padding: 1.25rem; }
  .section-heading.compact > p { margin-left: 0; }
  .family-note { text-align: left; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 390px) {
  .person-card { grid-template-columns: 43% 57%; min-height: 165px; }
  .person-card > div:last-child { padding: .8rem; }
  .person-card h4, .friend-card h3 { font-size: 1.15rem; }
  .resident-card h3 { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
  .speak-button.is-speaking { animation: none; }
}
