/*
  The coding site's home page only (source/index.html). Everything is scoped to body.home, so
  the posts, the other pages and English News Korea never see these rules.

  One shape: a square with its top-left corner cut off, the pin-1 mark on the PIC32MZ and its
  square pad on every header. It is the corner of the photos' pads and of every button, the
  bullet beside each post and the pins in the band. The colours are site.css's, plus one accent
  (--h-accent) for the pads, in both themes.
*/

body.home {
    /* The accent: the pads, the buttons and the bullets. */
    --h-accent: #2563eb;
    --h-on-accent: #ffffff;
    --h-accent-hover: #3b76f5;
    --h-deep: #20232a;
    --h-on-deep: #ffffff;
    --h-on-deep-soft: #c9ceda;
    --h-field: #e9ebf1;
    --h-cut: polygon(18% 0, 100% 0, 100% 100%, 0 100%, 0 18%);
    --h-cut-small: polygon(30% 0, 100% 0, 100% 100%, 0 100%, 0 30%);
    /* The first screen's pad: its border round the photo, and a corner cut small enough to pass
       clear of the photo's square corner. */
    --h-pad-border: clamp(2rem, 3.5vw, 3.5rem);
    --h-pad-cut: calc(var(--h-pad-border) * 1.3);
    --h-cut-big: polygon(var(--h-pad-cut) 0, 100% 0, 100% 100%, 0 100%, 0 var(--h-pad-cut));
    --h-cut-button: polygon(0.75rem 0, 100% 0, 100% 100%, 0 100%, 0 0.75rem);

    /* The five sizes on the page. */
    --h-s1: clamp(3.25rem, 1rem + 6vw, 6rem);
    --h-s2: clamp(2rem, 1.2rem + 2.6vw, 3.25rem);
    --h-s3: 1.25rem;
    --h-s4: 1.0625rem;
    --h-s5: 0.875rem;

    --h-margin: max(var(--gutter), calc((100vw - var(--wide)) / 2 + var(--gutter)));
    --h-gap: clamp(5.5rem, 3rem + 5vw, 8.5rem);
    --h-ease: cubic-bezier(0.2, 0.7, 0.1, 1);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) body.home { --h-deep: #15171c; --h-field: #2b2f38; }
}
:root[data-theme="dark"] body.home { --h-deep: #15171c; --h-field: #2b2f38; }

body.home { overflow-x: hidden; }
body.home .site-header { border-bottom: 0; }
body.home main { max-width: none; padding: 0; }
body.home .site-footer { border-top: 0; }

.home .h-wrap { max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter); }
.home h2, .home h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.05; }
.home h2 { font-size: var(--h-s2); }

/* ---------- Buttons ---------- */

.home .h-button {
    display: inline-block;
    padding: 0.95rem 1.6rem 0.95rem 1.9rem;
    background: var(--h-accent);
    color: var(--h-on-accent);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--h-s4);
    text-decoration: none;
    clip-path: var(--h-cut-button);
    transition: transform 160ms var(--h-ease), background-color 160ms;
}
.home .h-button:hover { background: var(--h-accent-hover); color: var(--h-on-accent); transform: translateY(-2px); }
.home .h-button:active { transform: translateY(1px); }
.home .h-button:focus-visible { outline: 3px solid var(--mask); outline-offset: 3px; clip-path: none; }

/* ---------- First screen: the big pad, the headline, the Scorpio ---------- */

/* The text and the pad share the page's margins, so the first screen is as centred as the rest.
   The pad is only as big as the photo on it plus an even border, and sits level with the text. */
.h-hero {
    display: grid;
    grid-template-columns: var(--h-margin) minmax(0, 11fr) 3rem minmax(0, 9fr) var(--h-margin);
    /* Short enough for the topic bar under it to show on the first screen. */
    min-height: min(calc(100svh - 4rem - 5.75rem), 56rem);
    overflow: hidden;
}
.h-hero-text { grid-column: 2; align-self: center; padding: 3rem 0 4rem; container-type: inline-size; }
/* As large as the scale allows while "without Harmony" still fits on one line of its column. */
.h-hero h1 {
    font-size: min(var(--h-s1), 13.2cqi);
    line-height: 0.92;
    letter-spacing: -0.035em;
    margin: 0 0 2rem;
}
.h-lede { font-size: var(--h-s3); line-height: 1.5; max-width: 34rem; margin: 0 0 1.75rem; }
.h-search { display: flex; max-width: 30rem; margin: 0 0 1.75rem; border: 2px solid var(--ink); background: var(--surface); }
.h-search:focus-within { border-color: var(--h-accent); outline: 2px solid var(--h-accent); outline-offset: 2px; }
.h-search input { flex: 1; min-width: 0; font: inherit; font-size: var(--h-s4); color: var(--ink); background: transparent; border: 0; padding: 0.75rem 0.9rem; outline: 0; }
.h-search button { font-family: var(--font-display); font-weight: 600; font-size: var(--h-s4); color: var(--paper); background: var(--ink); border: 0; padding: 0 1.2rem; cursor: pointer; }
.h-search button:hover { background: var(--h-accent); color: var(--h-on-accent); }
.h-tools { margin: 1.75rem 0 0; font-size: var(--h-s4); color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.2rem 1rem; }
.h-tools a { color: var(--ink); font-weight: 600; }
.h-tools a:hover { color: var(--mask); }
.h-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 2rem; margin: 0; }
.h-quiet { color: var(--ink); font-weight: 600; }
.h-quiet:hover { color: var(--mask); }

.h-hero-pad {
    grid-column: 4;
    align-self: center;
    display: grid;
    place-items: center;
    padding: var(--h-pad-border) var(--h-pad-border) clamp(1.25rem, 2vw, 2rem);
    background: var(--h-accent);
    clip-path: var(--h-cut-big);
}
.h-hero-photo { margin: 0; width: min(100%, 30rem, 60svh); }
.h-shutter { overflow: hidden; }
.h-shutter img { display: block; width: 100%; height: auto; }
.h-hero-photo figcaption { margin-top: 0.9rem; font-size: var(--h-s5); font-weight: 600; color: var(--h-on-accent); text-align: center; }

/* ---------- The guide ---------- */

.h-guide { padding-top: calc(var(--h-gap) - 2rem); }
/* The topic bar: under the first screen, then fixed to the top of the window through the guide. */
.h-topics {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--paper);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    font-family: var(--font-display);
    font-size: var(--h-s4);
}
.h-topics-row { display: flex; flex-wrap: wrap; gap: 0 1.5rem; padding-top: 0.55rem; padding-bottom: 0.55rem; }
.h-topics a { color: var(--ink); text-decoration: none; padding: 0.3rem 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.h-topics a:hover { color: var(--mask); }
.h-topics a.here { border-bottom-color: var(--h-accent); font-weight: 600; }

.h-topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 5rem; align-items: start; }
.h-topic { padding-top: 6rem; scroll-margin-top: 4.5rem; }
/* Each topic's name sits on a bar of the accent, cut like the pads. */
.h-topic-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.85rem 1.25rem 0.75rem 1.6rem;
    background: var(--h-accent);
    color: var(--h-on-accent);
    clip-path: var(--h-cut-button);
}
.h-topic h3 { font-size: var(--h-s2); color: var(--h-on-accent); }
.h-count { font-size: var(--h-s4); white-space: nowrap; }
.h-blurb { margin: 1.1rem 0 2.25rem; max-width: 40rem; font-size: var(--h-s4); }

.h-posts {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    display: grid;
    gap: 2rem;
}
.h-posts li { display: grid; grid-template-columns: 1.25rem minmax(0, 1fr); gap: 1.1rem; align-items: start; }
.h-bullet {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.2rem;
    background: var(--h-accent);
    clip-path: var(--h-cut-small);
}
.h-post-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin: 0;
    font-family: var(--font-display);
    font-size: var(--h-s3);
    line-height: 1.25;
}
.h-post-line a { color: var(--ink); text-decoration: none; font-weight: 600; }
.h-post-line a:hover { color: var(--mask); text-decoration: underline; text-decoration-thickness: 2px; }
.h-post-line time { font-family: var(--font-body); font-size: var(--h-s4); color: var(--muted); font-variant-numeric: tabular-nums; }
.h-post-summary { margin: 0.45rem 0 0; font-size: var(--h-s4); line-height: 1.55; max-width: 46ch; }
/* A short progress note or announcement (brief: true in the post): quieter than a chapter. */
.h-posts li.brief .h-bullet { width: 0.7rem; height: 0.7rem; margin: 0.4rem 0 0 0.55rem; background: var(--muted); }
.h-posts li.brief .h-post-line { font-size: var(--h-s4); }
.h-posts li.brief .h-post-line a { font-weight: 400; }
.h-posts li.brief .h-post-summary { font-size: var(--h-s5); color: var(--muted); margin-top: 0.25rem; }

/* ---------- The band: one pin per post, pin 1 cut ---------- */

.h-header-band { margin-top: var(--h-gap); background: var(--h-deep); padding: 2.25rem 0; }
/* One row of 41 on wide screens; three rows of 14 on phones, like a dual-row header. */
.h-pins { display: grid; grid-template-columns: repeat(41, minmax(0, 1fr)); gap: 0.5rem 0.4rem; }
.h-pin {
    aspect-ratio: 1;
    background: var(--h-accent);
    transition: transform 160ms var(--h-ease), background-color 160ms;
}
.h-pin.one { clip-path: var(--h-cut-small); }
.h-pin:hover, .h-pin:focus-visible { background: #ffffff; transform: translateY(-3px); }
.h-pin:focus-visible { outline: 2px solid var(--h-accent); outline-offset: 3px; }

/* ---------- The clock ---------- */

.h-clock { padding: var(--h-gap) 0; background: var(--h-field); }
.h-clock-grid {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 6fr);
    grid-template-areas: "intro out" "form out";
    gap: 2.5rem 4rem;
    align-items: start;
}
.h-clock-intro { grid-area: intro; }
.h-clock-form { grid-area: form; }
/* The answer sits on its own panel, like the display of a meter. */
.h-clock-out { grid-area: out; background: var(--paper); padding: clamp(1.5rem, 1rem + 2vw, 2.75rem); }
.h-clock-intro > p { font-size: var(--h-s4); margin: 1.5rem 0 0; max-width: 30rem; }
.h-clock-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 9rem;
    gap: 0.9rem 1.25rem;
    align-items: center;
    max-width: 30rem;
}
.h-clock-form label { font-size: var(--h-s4); }
.h-clock-form select, .h-clock-form input {
    font: inherit;
    font-size: var(--h-s4);
    width: 100%;
    min-height: 2.75rem;
    padding: 0.4rem 0.6rem;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--muted);
    border-radius: 0;
}
.h-clock-form input:disabled { color: var(--muted); }
.h-clock-form select:focus-visible, .h-clock-form input:focus-visible { outline: 3px solid var(--h-accent); outline-offset: 1px; }

.h-mhz { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: var(--h-s1); line-height: 0.95; letter-spacing: -0.035em; }
.h-mhz output { font-variant-numeric: tabular-nums; }
.h-chain { margin: 1.25rem 0 0.5rem; font-size: var(--h-s3); line-height: 1.45; }
.h-check { margin: 0 0 2rem; font-size: var(--h-s4); font-weight: 600; }
.h-check.bad { color: #c2410c; }
:root[data-theme="dark"] .h-check.bad { color: #ffa36b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .h-check.bad { color: #ffa36b; } }
.h-code { position: relative; min-width: 0; }
.h-code pre {
    margin: 0;
    padding: 1.25rem 1.25rem 1.25rem;
    overflow-x: auto;
    background: var(--h-deep);
    color: var(--h-on-deep);
    border: 0;
    border-radius: 0;
    font-size: 0.875rem;
    line-height: 1.7;
}
.h-copy {
    margin-top: 1rem;
    font: inherit;
    font-weight: 600;
    font-size: var(--h-s4);
    padding: 0.6rem 1.2rem 0.6rem 1.4rem;
    border: 0;
    background: var(--ink);
    color: var(--paper);
    clip-path: var(--h-cut-button);
    cursor: pointer;
    transition: transform 160ms var(--h-ease);
}
.h-copy:hover { transform: translateY(-2px); }
.h-copy:active { transform: translateY(1px); }

/* ---------- Built along the way: names on the left, the picture on a pad ---------- */

.h-builds { padding: var(--h-gap) 0; }
.h-builds-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 3rem; align-items: center; }
.h-builds-list { min-width: 0; }
.h-builds-list h2 { margin-bottom: 0.25rem; }
.h-builds-list h2 { color: var(--muted); }
.h-builds-list ul { list-style: none; margin: 0; padding: 0; }
.h-build-name {
    font: inherit;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--h-s2);
    line-height: 1.15;
    letter-spacing: -0.02em;
    padding: 0.1rem 0;
    border: 0;
    background: none;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    transition: color 160ms, transform 200ms var(--h-ease);
}
.h-build-name:hover { color: var(--mask); transform: translateX(6px); }
.h-build-name[aria-pressed="true"] { color: var(--mask); }
.h-build-name[aria-pressed="true"]::before {
    content: "";
    display: inline-block;
    width: 0.55em;
    height: 0.55em;
    margin-right: 0.35em;
    background: var(--h-accent);
    clip-path: var(--h-cut-small);
    vertical-align: 0.08em;
}

/* Each picture sits in the middle of its own pad, its caption underneath. */
.h-builds-stage { display: grid; }
.h-build { grid-area: 1 / 1; margin: 0; }
.h-build-pad { background: var(--h-accent); clip-path: var(--h-cut); padding: 11%; }
.h-build img { display: block; width: 100%; height: auto; }
.h-build figcaption { margin-top: 1.1rem; padding: 1rem 1.25rem 1.1rem 0; font-size: var(--h-s4); line-height: 1.55; max-width: 34rem; background: var(--paper); }

/* With the script, one picture at a time; without it, all of them in a column. */
.home-js .h-build { opacity: 0; visibility: hidden; transition: opacity 300ms, visibility 0s 300ms; }
.home-js .h-build.on { opacity: 1; visibility: visible; transition: opacity 300ms; }
html:not(.home-js) .h-build-name { cursor: default; }
html:not(.home-js) .h-builds-stage { gap: 3rem; }
html:not(.home-js) .h-build { grid-area: auto; }

/* ---------- About: a deep panel ---------- */

.h-about { padding: 0 20px 20px; }
.h-about-panel {
    background: var(--h-deep);
    color: var(--h-on-deep);
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 3rem;
    /* The text lines up with the page's margins although the panel is inset 20px. */
    padding: 4.5rem calc(var(--h-margin) - 20px) 0;
}
.h-about-left h2 { color: var(--h-on-deep); }
.h-about-photo {
    display: block;
    width: min(100%, 26rem);
    height: auto;
    margin: 3.5rem 0 -5rem;
}
.h-about-right { display: grid; align-content: start; gap: 2.75rem; padding: 0.5rem 0 5rem; }
.h-about-right h3 { font-size: var(--h-s3); color: var(--h-on-deep); margin-bottom: 0.6rem; letter-spacing: -0.01em; }
.h-about-right p { margin: 0; font-size: var(--h-s4); line-height: 1.6; max-width: 30rem; color: var(--h-on-deep); }
.h-about-right a:not(.h-button) { color: var(--h-on-deep); text-decoration-thickness: 2px; }

/* ---------- Motion ---------- */

/* Opens downwards. */
@keyframes h-shutter-open {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0 0 0 0); }
}
@keyframes h-settle { from { transform: scale(1.12); } to { transform: scale(1); } }
@keyframes h-pad-in { from { transform: translateX(8%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes h-rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: no-preference) {
    .h-hero-pad { animation: h-pad-in 900ms var(--h-ease) both; }
    .h-shutter { animation: h-shutter-open 1100ms var(--h-ease) 200ms both; }
    .h-shutter img { animation: h-settle 1600ms var(--h-ease) 200ms both; }
    .h-hero h1 { animation: h-rise 700ms var(--h-ease) 100ms both; }
    .h-lede { animation: h-rise 700ms var(--h-ease) 180ms both; }
    .h-search { animation: h-rise 700ms var(--h-ease) 230ms both; }
    .h-actions { animation: h-rise 700ms var(--h-ease) 280ms both; }
    .h-tools { animation: h-rise 700ms var(--h-ease) 330ms both; }

    .home-js .reveal { opacity: 0; transform: translateY(24px); transition: opacity 700ms var(--h-ease), transform 700ms var(--h-ease); }
    .home-js .reveal.in { opacity: 1; transform: none; }
    .home-js .h-topic.reveal .h-posts li { opacity: 0; transform: translateY(16px); transition: opacity 600ms var(--h-ease), transform 600ms var(--h-ease); }
    .home-js .h-topic.reveal.in .h-posts li { opacity: 1; transform: none; }
    .home-js .h-topic.in .h-posts li:nth-child(2) { transition-delay: 70ms; }
    .home-js .h-topic.in .h-posts li:nth-child(3) { transition-delay: 140ms; }
    .home-js .h-topic.in .h-posts li:nth-child(4) { transition-delay: 210ms; }
    .home-js .h-topic.in .h-posts li:nth-child(n+5) { transition-delay: 280ms; }
    .h-about-photo { transition: transform 1200ms var(--h-ease); }
    .h-about-photo.drift { transform: translateY(-1.5rem); }
}

/* ---------- Tablets and phones ---------- */

@media (max-width: 900px) {
    .h-hero { grid-template-columns: var(--gutter) minmax(0, 1fr) var(--gutter); min-height: 0; }
    .h-hero-text { padding: 2.5rem 0; }
    .h-hero-pad { grid-column: 1 / -1; padding: 3rem 1.5rem 2rem; }
    .h-hero-photo { width: min(80%, 26rem); }
    @media (prefers-reduced-motion: no-preference) {
        .h-hero-pad { animation: h-rise 900ms var(--h-ease) both; }
    }

    .h-topic-grid { grid-template-columns: 1fr; }
    .h-pins { grid-template-columns: repeat(21, minmax(0, 1fr)); }
    .h-topic { padding-top: 4.5rem; scroll-margin-top: 3.25rem; }
    /* The topic bar is one row that scrolls sideways, like the site's menu. */
    .h-topics-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .h-topics-row::-webkit-scrollbar { display: none; }

    /* The answer above the inputs, like a calculator's display above its keys. */
    .h-clock-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "intro" "out" "form"; gap: 3rem 2.5rem; }
    .h-builds-grid { grid-template-columns: 1fr; gap: 2rem; }
    .h-builds-list ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }
    .h-build-name { font-size: 1.625rem; }
    .h-builds-list h2 { margin-bottom: 1rem; }

    .h-about { padding: 0 10px 10px; }
    .h-about-panel { grid-template-columns: 1fr; padding: 3rem var(--gutter) 0; margin: 0; }
    .h-about-right { padding: 0; order: 1; }
    .h-about-left { order: 2; }
    .h-about-left h2 { margin-bottom: 0; }
    .h-about-photo { width: 86%; margin: 2.5rem auto -4rem; }
    .h-about-left { display: contents; }
    .h-about-left h2 { order: 0; }
    .h-about-photo { order: 3; }
}

@media (max-width: 560px) {
    .h-pins { grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 0.55rem 0.45rem; }
    .h-clock-form { grid-template-columns: minmax(0, 1fr) 7.5rem; }
}
