:root {
  --ink: #202122;
  --muted: #54595d;
  --line: #a2a9b1;
  --soft-line: #c8ccd1;
  --link: #36c;
  --pale-blue: #eaecf0;
  --infobox: #f8f9fa;
  --taxon: #b0e0e6;
  --pink: #ff5ca8;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body { margin: 0; color: var(--ink); background: #fff; font-family: var(--sans); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.sr-only { width: 1px; height: 1px; padding: 0; position: absolute; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.wiki-top { height: 70px; padding: 8px clamp(14px, 2.4vw, 42px); display: grid; grid-template-columns: 250px minmax(280px, 500px) 1fr; align-items: center; gap: 28px; background: #fff; border-bottom: 1px solid #eaecf0; }
.wiki-identity { display: flex; align-items: center; gap: 16px; min-width: 0; }
.menu-button { width: 28px; height: 28px; padding: 5px; display: grid; align-content: center; gap: 4px; border: 0; background: transparent; cursor: pointer; }
.menu-button span { height: 2px; display: block; background: var(--ink); }
.wiki-brand { display: flex; align-items: center; gap: 8px; color: #000; text-decoration: none; }
.wiki-brand:hover { text-decoration: none; }
.wiki-brand img { width: 48px; height: 52px; object-fit: contain; }
.wiki-brand b { display: block; font: 24px/.9 var(--serif); letter-spacing: .02em; }
.wiki-brand small { display: block; margin-top: 5px; font: 10px/1 var(--serif); letter-spacing: .04em; }
.wiki-search { height: 34px; display: grid; grid-template-columns: 32px 1fr 72px; border: 1px solid #72777d; }
.wiki-search > span { display: grid; place-items: center; color: #72777d; font-size: 20px; }
.wiki-search input { min-width: 0; border: 0; outline: 0; font-size: 14px; }
.wiki-search button { border: 0; border-left: 1px solid #a2a9b1; background: #f8f9fa; font-weight: 700; cursor: pointer; }
.user-links { display: flex; justify-content: flex-end; align-items: center; gap: 13px; white-space: nowrap; font-size: 12px; }
.user-links button { padding: 4px; border: 0; background: transparent; font-weight: 700; cursor: pointer; }

.wiki-shell { width: min(1530px, 100%); height: calc(100vh - 70px); margin: 0 auto; padding: 17px clamp(14px, 2.4vw, 42px) 14px; display: grid; grid-template-columns: 168px minmax(0, 1fr) 286px; gap: clamp(20px, 2.5vw, 40px); overflow: hidden; }
.toc { min-height: 0; padding-top: 44px; font-size: 12px; line-height: 1.35; }
.toc-heading { padding-bottom: 8px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--soft-line); }
.toc-heading button { padding: 2px 6px; border: 0; border-radius: 2px; background: var(--pale-blue); color: var(--muted); font-size: 10px; }
.toc nav { padding: 8px 0 10px; display: grid; gap: 7px; }
.toc nav a { color: var(--ink); }
.toc nav a:hover { color: var(--link); }
.toc nav a.active { font-weight: 700; }
.toc nav span { display: inline-block; min-width: 24px; color: var(--muted); }
.toc nav .sub { padding-left: 26px; color: var(--muted); }
.toc-tools { padding-top: 9px; display: grid; gap: 5px; border-top: 1px solid var(--soft-line); color: var(--muted); font-size: 11px; }
.toc-tools b { margin-bottom: 2px; color: var(--ink); }
.toc-tools label { display: flex; align-items: center; gap: 5px; }
.toc-tools input { width: 12px; height: 12px; margin: 0; accent-color: var(--link); }
.random-fact { margin-top: 13px; padding: 6px 8px; border: 1px solid #a2a9b1; background: #f8f9fa; color: var(--ink); font-size: 11px; font-weight: 700; cursor: pointer; }
.toc > p { margin: 7px 0 0; color: var(--muted); font: 10px/1.35 var(--sans); }

.article { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; font-family: var(--serif); }
.article-header { font-family: var(--sans); }
.title-line { height: 45px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font: 36px/1.12 var(--serif); font-weight: 400; letter-spacing: -.02em; }
.title-line button { padding: 5px 8px; border: 0; background: transparent; color: var(--link); font-size: 12px; font-weight: 700; }
.article-nav { height: 33px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--soft-line); font: 12px var(--sans); }
.article-nav div { display: flex; gap: 18px; }
.article-nav a { padding-top: 10px; color: var(--ink); }
.article-nav a.selected { color: var(--ink); border-bottom: 2px solid var(--link); }
.hatnote { padding: 9px 0 5px; font-size: 12px; font-style: italic; }
.lead { font-size: clamp(12px, .88vw, 14px); line-height: 1.43; }
.lead p { margin: 6px 0; }
sup { line-height: 0; font-family: var(--sans); font-size: 9px; }
.article-columns { min-height: 0; margin-top: 4px; display: grid; flex: 1; grid-template-columns: 1fr 1fr; gap: 22px; font-size: clamp(11px, .76vw, 13px); line-height: 1.38; }
.article-columns > div { display: flex; flex-direction: column; gap: 3px; }
.wiki-section { break-inside: avoid; }
.wiki-section h2 { margin: 8px 0 5px; padding-bottom: 3px; border-bottom: 1px solid var(--line); font: 21px/1.15 var(--serif); font-weight: 400; }
.wiki-section h2 a { float: right; margin-top: 7px; font: 10px var(--sans); }
.wiki-section p { margin: 5px 0; }
.wikitable { width: 100%; margin: 7px 0; border-collapse: collapse; background: #f8f9fa; font: 10px/1.25 var(--sans); }
.wikitable th, .wikitable td { padding: 4px 6px; border: 1px solid #a2a9b1; text-align: left; }
.wikitable th { background: #eaecf0; }
blockquote { margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--line); background: #f8f9fa; font-style: italic; }
blockquote cite { display: block; margin-top: 3px; color: var(--muted); font: 9px var(--sans); }
.article-footer { margin-top: 6px; padding-top: 6px; display: grid; gap: 2px; border-top: 1px solid var(--line); font-size: 9px; line-height: 1.25; }
.article-footer b { font: 17px var(--serif); }

.infobox { height: 100%; min-height: 0; align-self: stretch; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); background: var(--infobox); font-size: 10px; line-height: 1.25; }
.infobox-title { padding: 7px; background: var(--taxon); text-align: center; }
.infobox-title b { display: block; font: 700 16px var(--sans); }
.infobox-title i { display: block; margin-top: 2px; font-family: var(--serif); }
.specimen-photo { margin: 0; padding: 6px 8px 3px; }
.specimen-photo img { width: 100%; height: clamp(105px, 15vh, 145px); display: block; border: 1px solid #72777d; object-fit: cover; }
.specimen-photo figcaption { padding-top: 3px; text-align: center; }
.status-box { margin: 2px 8px 5px; padding: 5px; display: grid; gap: 3px; background: #d9ead3; text-align: center; }
.status-box span { font-weight: 700; }
.status-box i { width: 9px; height: 9px; display: inline-block; margin-right: 3px; border-radius: 50%; background: #60b044; }
.infobox table { width: calc(100% - 16px); margin: 0 8px; border-collapse: collapse; }
.infobox th { padding: 4px; background: var(--taxon); font-size: 11px; }
.infobox td { padding: 2px 5px; }
.infobox td:first-child { width: 42%; text-align: right; }
.binomial { margin: 5px 8px; display: grid; text-align: center; }
.binomial b { padding: 4px; background: var(--taxon); }
.binomial i { padding-top: 4px; font: 13px var(--serif); }
.binomial span { color: var(--muted); }
.interactive-specimen { min-height: 150px; margin: 6px 8px 8px; flex: 1; position: relative; overflow: hidden; border: 1px solid #72777d; background: linear-gradient(rgba(0, 35, 68, .08), rgba(0, 20, 44, .34)), url("assets/blue-whale-dih-hero.jpg") 92% 50% / auto 190% no-repeat; }
.interaction-label { padding: 4px 6px; display: flex; justify-content: space-between; position: absolute; inset: 0 0 auto; z-index: 2; color: white; background: rgba(0, 0, 0, .56); font-size: 9px; }
.interaction-label span { text-transform: uppercase; letter-spacing: .05em; }
#dihTrigger { width: 100%; height: 100%; padding: 0; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; touch-action: manipulation; }
#dihTrigger img { width: 77%; height: 77%; object-fit: contain; filter: drop-shadow(5px 8px 0 rgba(27, 0, 15, .25)) drop-shadow(0 0 9px rgba(255, 92, 168, .5)); transform-origin: 42% 84%; animation: dihFloat 2.8s ease-in-out infinite; }
#dihTrigger:hover img { filter: brightness(1.08) drop-shadow(5px 9px 0 rgba(27, 0, 15, .3)); }
#dihTrigger:focus-visible { outline: 3px solid #fff; outline-offset: -5px; }
#dihTrigger.is-firing img { animation: dihKick .8s cubic-bezier(.16, .84, .25, 1) both; }

.foam-layer { position: fixed; inset: 0; z-index: 1000; overflow: hidden; pointer-events: none; visibility: hidden; perspective: 700px; }
.foam-layer.is-active { visibility: visible; }
.foam-layer::before { content: ""; position: absolute; inset: -18%; z-index: 2; opacity: 0; border-radius: 50%; background: #fff; transform: scale(.03); }
.foam-layer.is-active::before { animation: whiteFlash 1.2s cubic-bezier(.2, .72, .18, 1) both; }
.spray-particle { width: var(--size); height: var(--size); position: absolute; left: var(--x); top: var(--y); z-index: 1; opacity: 0; border: 1px solid rgba(204, 238, 248, .95); border-radius: var(--radius); background: #fff; box-shadow: 0 0 8px #fff, inset -3px -3px 5px rgba(120, 205, 235, .22); transform: translate(-50%, -50%) scale(.08) translateZ(-300px); animation: sprayForward var(--duration) cubic-bezier(.08, .58, .12, 1) var(--delay) both; }
.spray-particle.side-spray { animation-name: spraySide; }
@keyframes dihFloat { 0%, 100% { transform: translateY(3px) rotate(-1deg); } 50% { transform: translateY(-5px) rotate(2deg); } }
@keyframes dihKick { 0% { transform: scale(1); } 18% { transform: scale(.82, 1.12) rotate(-5deg); } 36% { transform: scale(1.14, .88) translateY(-6px) rotate(4deg); } 100% { transform: scale(1); } }
@keyframes whiteFlash { 0%, 18% { opacity: 0; transform: scale(.03); } 36%, 60% { opacity: 1; transform: scale(1.5); border-radius: 0; } 100% { opacity: 0; transform: scale(1.6); border-radius: 0; } }
@keyframes sprayForward { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.08) translateZ(-300px); filter: blur(0); } 10% { opacity: 1; } 68% { opacity: .96; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--scale)) translateZ(360px) rotate(var(--spin)); filter: blur(var(--blur)); } }
@keyframes spraySide { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.12); } 12% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--scale)) rotate(var(--spin)); } }

@media (max-width: 1040px) {
  .wiki-top { grid-template-columns: 210px minmax(220px, 1fr) auto; gap: 14px; }
  .wiki-brand b { font-size: 20px; }
  .wiki-brand small { font-size: 8px; }
  .wiki-shell { grid-template-columns: 140px minmax(0, 1fr) 250px; gap: 16px; }
  .toc { font-size: 10px; }
  .article-columns { gap: 14px; }
  .lead { font-size: 12px; }
  .wiki-section { font-size: 10.5px; }
}

@media (max-width: 760px) {
  .wiki-top { height: 58px; padding: 5px 10px; grid-template-columns: auto minmax(180px, 1fr) auto; gap: 8px; }
  .menu-button { display: none; }
  .wiki-brand img { width: 38px; height: 42px; }
  .wiki-brand b { font-size: 17px; }
  .wiki-brand small, .user-links a:nth-child(-n+2) { display: none; }
  .wiki-search { height: 31px; grid-template-columns: 26px 1fr; }
  .wiki-search button { display: none; }
  .user-links { gap: 5px; }
  .wiki-shell { height: calc(100vh - 58px); padding: 9px 9px 8px; grid-template-columns: minmax(0, 1fr) minmax(220px, 38%); gap: 10px; }
  .toc { display: none; }
  .title-line { height: 38px; }
  h1 { font-size: clamp(25px, 5vw, 32px); }
  .title-line button { font-size: 9px; }
  .article-nav { height: 28px; font-size: 10px; }
  .article-nav div { gap: 9px; }
  .article-nav a { padding-top: 8px; }
  .article-nav div:last-child a:nth-child(2), .article-nav div:last-child a:nth-child(3) { display: none; }
  .hatnote { padding-top: 5px; font-size: 9px; }
  .lead { font-size: clamp(9.5px, 1.6vw, 11px); line-height: 1.32; }
  .lead p { margin: 4px 0; }
  .article-columns { grid-template-columns: 1fr 1fr; gap: 9px; font-size: clamp(8.5px, 1.42vw, 10px); line-height: 1.27; }
  .wiki-section h2 { margin-top: 5px; font-size: clamp(14px, 2.8vw, 18px); }
  .wiki-section p { margin: 3px 0; }
  .article-footer { font-size: 7.5px; }
  .article-footer b { font-size: 13px; }
  .infobox { font-size: 8px; }
  .infobox-title { padding: 5px; }
  .infobox-title b { font-size: 13px; }
  .specimen-photo { padding: 4px 5px 2px; }
  .specimen-photo img { height: clamp(90px, 14vh, 120px); }
  .status-box { margin: 2px 5px 4px; padding: 3px; }
  .infobox table { width: calc(100% - 10px); margin: 0 5px; }
  .infobox th { padding: 3px; font-size: 9px; }
  .infobox td { padding: 1px 3px; }
  .binomial { margin: 3px 5px; }
  .binomial b { padding: 3px; }
  .binomial i { font-size: 10px; }
  .interactive-specimen { min-height: 130px; margin: 4px 5px 5px; }
}

@media (max-height: 720px) {
  .wiki-top { height: 58px; }
  .wiki-shell { height: calc(100vh - 58px); padding-top: 9px; }
  .toc { padding-top: 34px; }
  .toc nav { gap: 4px; }
  .title-line { height: 37px; }
  h1 { font-size: 29px; }
  .article-nav { height: 27px; }
  .hatnote { padding: 5px 0 2px; }
  .lead { font-size: 11px; line-height: 1.3; }
  .article-columns { font-size: 9.5px; line-height: 1.25; }
  .wiki-section h2 { margin-top: 5px; font-size: 17px; }
  .wiki-section p { margin: 3px 0; }
  .specimen-photo img { height: 85px; }
  .interactive-specimen { min-height: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  #dihTrigger img, #dihTrigger.is-firing img { animation: none; }
  .foam-layer.is-active::before { animation-duration: .55s; }
  .spray-particle { animation-duration: .8s !important; }
}
