.history-hero,
.history-topics,
.history-editorial {
    width: min(88%, 1280px);
    margin-inline: auto;
}

.history-hero {
    display: grid;
    align-items: center;
    min-height: 340px;
    overflow: hidden;
    border-radius: 18px;
    color: #fcfbf8;
    background: #251b20;
}

.history-hero-with-photo { grid-template-columns: minmax(0, 1fr) minmax(0, .95fr); }

.history-hero-copy { padding: clamp(28px, 7vw, 96px); }

.history-hero h1 {
    margin: 0;
    font-size: clamp(2.45rem, 6vw, 6.5rem);
    line-height: 1.02;
    overflow-wrap: anywhere;
}

.history-hero p {
    max-width: 52ch;
    margin: 20px 0 0;
    color: #f0e7e8;
    font-size: clamp(.95rem, 1.5vw, 1.22rem);
}

.history-hero .button { margin-top: 24px; }
.history-hero :focus-visible { outline-color: #ffbdcc; }

.history-hero-photo {
    position: relative;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    min-height: 420px;
    margin: 0;
}

.history-hero-photo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 22%;
}

.history-hero-photo figcaption {
    position: absolute;
    inset: auto 0 0;
    padding: 26px 20px 14px;
    background: linear-gradient(transparent, #1a1216eb);
    font-size: .78rem;
}

.history-topics {
    margin-block: clamp(38px, 6vw, 90px);
    scroll-margin-top: 7rem;
}

.history-topics h2,
.history-editorial h2 {
    margin: 0 0 20px;
    font-size: clamp(1.6rem, 3vw, 2.9rem);
    line-height: 1.15;
}

.history-topic-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(12px, 1.8vw, 24px);
}
.history-practice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.history-topic {
    min-height: 240px;
    min-width: 0;
    padding: clamp(22px, 3.4vw, 44px);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: linear-gradient(#efe7dee6, #efe7dee6), url('/media/wave-lines.svg') center bottom / 100% auto no-repeat, #efe7de;
    overflow-wrap: anywhere;
}

.history-topic[data-topic="maestri"] { background: #f7e9eb; }
.history-topic[data-topic="giappone"] {
    background: linear-gradient(#eae5ddeb, #eae5ddeb), url('/media/torii-sun.svg') right bottom / 64% auto no-repeat, #eae5dd;
}
.history-topic.history-topic-preview {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: 170px;
    background: #fcfbf8;
}
.history-practice-mark {
    position: absolute;
    z-index: -1;
    pointer-events: none;
    width: clamp(125px, 19vw, 215px);
    height: auto;
    opacity: .09;
}
.history-practice-mark img { display: block; width: 100%; height: auto; }
[data-practice="kumite"] .history-practice-mark {
    inset-inline-end: -8%;
    bottom: -36%;
    filter: grayscale(1);
    transform: rotate(-13deg);
}
.history-topic[data-practice="kihon"] {
    background: linear-gradient(#f7f1e9ed, #f7f1e9ed), url('/media/wave-lines.svg') center bottom / 100% auto no-repeat, #f7f1e9;
}
[data-practice="kihon"] .history-practice-mark {
    inset-inline-end: 7%;
    bottom: -48%;
    opacity: .075;
}
.history-topic[data-practice="kata"] { background: #f8efed; }
[data-practice="kata"] .history-practice-mark {
    inset-inline-end: -14%;
    bottom: -31%;
    transform: scale(1.23);
}
.history-topic[data-practice="tameshiwari"] {
    background: linear-gradient(#f3eee5ed, #f3eee5ed), url('/media/wave-lines.svg') right bottom / 84% auto no-repeat, #f3eee5;
}
[data-practice="tameshiwari"] .history-practice-mark {
    inset-inline-end: 2%;
    bottom: -34%;
    opacity: .075;
}
.history-preview { margin-block-end: clamp(32px, 6vw, 78px); }

.history-topic h3 { margin: 0; font-size: clamp(1.4rem, 2.5vw, 2.2rem); line-height: 1.12; }
.history-topic h3 a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    text-decoration: none;
}
.history-topic h3 a span { color: var(--accent); font-size: .9em; }
.history-topic h3 a:hover { text-decoration: underline; }
.history-topic p { margin: 12px 0 0; color: #493e40; }

.history-hero-reading {
    min-height: 300px;
    background: linear-gradient(100deg, #251b20 25%, #251b20c7), url('/media/wave-lines.svg') right center / min(70%, 860px) auto no-repeat, #251b20;
}

.history-hero-reading[data-topic="giappone"] {
    background: linear-gradient(100deg, #251b20 24%, #251b20bd), url('/media/torii-sun.svg') 95% center / auto 92% no-repeat, #251b20;
}

/* Reading layout: paths, article and chapter navigation. */
.history-document {
    --history-toc-height: 72px;
    width: min(94%, 1560px);
    margin: clamp(24px, 4vw, 56px) auto clamp(40px, 7vw, 100px);
    display: grid;
    grid-template-columns: 11rem minmax(0, 1fr) 14rem;
    gap: clamp(22px, 2.5vw, 44px);
    align-items: start;
}
.history-section-nav { grid-column: 1; grid-row: 1; }
.history-toc { grid-column: 3; grid-row: 1; z-index: 7; }
.history-reading-content { grid-column: 2; grid-row: 1; min-width: 0; width: 100%; max-width: 52rem; justify-self: center; }
.history-section-nav,
.history-toc {
    position: sticky;
    top: calc(var(--site-header-height, 6rem) + 20px);
    min-width: 0;
    max-height: calc(100dvh - var(--site-header-height, 6rem) - 40px);
    overflow-y: auto;
    scrollbar-width: thin;
}
.history-back-link { display: inline-flex; align-items: center; min-height: 44px; font-size: .85rem; }
.history-nav-label { margin: 16px 0 8px; font-size: .77rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #65575a; }
.history-section-nav ul,
.history-toc ol { list-style: none; padding: 0; margin: 0; }
.history-section-nav a:not(.history-back-link) {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: .85rem;
    text-decoration: none;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.history-section-nav a[aria-current="page"] { background: #f1e2e4; color: #84152e; font-weight: 700; }
.history-section-nav a:hover { text-decoration: underline; }
.history-toc details { margin: 0; }
.history-toc summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 8px 0;
    font-size: .85rem;
    font-weight: 700;
    line-height: 1.4;
    cursor: pointer;
    list-style: none;
}
.history-toc summary::-webkit-details-marker { display: none; }
.history-toc summary > span:first-child { min-width: 0; }
.history-toc-chevron { flex-shrink: 0; font-size: 1.1rem; transition: transform .2s ease; }
.history-toc details[open] .history-toc-chevron { transform: rotate(180deg); }
.history-toc [data-history-current] { display: none; }
.history-toc nav { max-height: calc(100dvh - var(--site-header-height, 6rem) - 100px); overflow-y: auto; scrollbar-width: thin; }
.history-toc li { margin: 0; }
.history-toc a {
    display: block;
    padding: 8px 12px;
    border-inline-start: 2px solid var(--line);
    font-size: .8rem;
    line-height: 1.5;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.history-toc a[aria-current="location"] { border-inline-start: 3px solid var(--accent); color: #84152e; background: #f3e9e6; font-weight: 700; }
.history-toc a:hover { text-decoration: underline; }
/* The document scroll padding already reserves space for the fixed site header. */
.history-document [data-reading-section] { scroll-margin-top: 24px; }
.history-chapter {
    padding: clamp(22px, 3vw, 36px);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fcfbf8;
    overflow-wrap: anywhere;
}
.history-chapter + .history-chapter,
.history-reading-content > .history-editorial + .history-chapter,
.history-reading-content > .history-chapter + .history-editorial { margin-top: 28px; }
.history-chapter h2 { margin: 0 0 20px; font-size: clamp(1.5rem, 2.4vw, 2.2rem); line-height: 1.25; }
.history-period { margin: 0 0 10px; color: #84152e; font-size: .8rem; font-weight: 600; }
.history-document .history-chapter .history-prose { padding: 0; }
.history-document .history-editorial { width: 100%; margin-inline: 0; margin-block: 0; padding: clamp(22px, 3vw, 36px); }
.history-document .history-editorial-with-image { grid-template-columns: minmax(0, 1fr); gap: 24px; }
.history-document .history-editorial-photo { width: 100%; max-width: 32rem; justify-self: center; }
.history-document .history-editorial h2 { font-size: clamp(1.5rem, 2.4vw, 2.2rem); line-height: 1.25; }
.history-document .history-next { max-width: 100%; margin-top: 24px; font-size: .85rem; }

@media (max-width: 1199px) {
    .history-document { display: block; width: min(88%, 850px); }
    .history-section-nav { position: static; max-height: none; overflow: visible; margin-bottom: 20px; }
    .history-section-nav ul { display: flex; flex-wrap: wrap; gap: 6px; }
    .history-section-nav a:not(.history-back-link) { border: 1px solid var(--line); font-size: .8rem; padding: 8px 12px; }
    .history-section-nav .history-nav-label { margin-top: 4px; }
    .history-toc { top: calc(var(--site-header-height, 6rem) + 8px); max-height: none; overflow: visible; margin-bottom: 22px; }
    .history-toc details { position: relative; border: 1px solid var(--line); border-radius: 12px; background: #fcfbf8; box-shadow: 0 5px 18px #251b200a; }
    .history-toc summary { min-height: 60px; padding: 10px 15px; }
    .history-toc [data-history-current] { display: block; margin-top: 4px; font-size: .77rem; font-weight: 400; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
    .history-toc nav { position: absolute; inset: 100% -1px auto; max-height: min(60dvh, calc(100dvh - var(--site-header-height, 6rem) - 130px)); overflow-y: auto; padding: 8px 10px 12px; border: 1px solid var(--line); border-radius: 0 0 12px 12px; background: #fcfbf8; box-shadow: 0 16px 22px #251b2020; overscroll-behavior: contain; }
    .history-toc a { min-height: 44px; display: flex; align-items: center; font-size: .85rem; }
    .history-document [data-reading-section] { scroll-margin-top: calc(var(--history-toc-height) + 28px); }
    .history-reading-content { max-width: none; }
}
@media (forced-colors: active) {
    .history-section-nav a[aria-current="page"],
    .history-toc a[aria-current="location"] { background: Highlight; color: HighlightText; }
    .history-toc details, .history-toc nav { background: Canvas; color: CanvasText; border-color: CanvasText; }
}

.history-prose {
    padding: 0 clamp(16px, 3vw, 28px) clamp(16px, 3vw, 28px);
    color: #443d3d;
    overflow-wrap: anywhere;
}
.history-prose p { max-width: 68ch; margin: 0 0 1em; white-space: pre-line; }
.history-prose p:last-child { margin-bottom: 0; }
.history-prose img { display: block; max-width: 100%; height: auto; border-radius: 10px; }
.history-prose .text-link { display: inline-flex; align-items: center; min-height: 44px; }

.history-editorial {
    margin-block: clamp(24px, 4vw, 52px);
    padding: clamp(20px, 4vw, 48px);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fcfbf8;
    scroll-margin-top: 20px;
}

.history-editorial#conclusione { background: #eee8e1; }
.history-editorial .history-prose { padding: 0; }
.history-editorial-with-image {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(24px, 5vw, 64px);
}
.history-editorial-photo { min-width: 0; margin: 0; text-align: center; }
.history-editorial-photo img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 340px;
    margin-inline: auto;
    border-radius: 12px;
}
.history-editorial-photo figcaption {
    margin-top: 9px;
    font-size: .78rem;
    color: #514747;
}
.history-prose .history-next { display: flex; width: fit-content; gap: 8px; margin-top: 12px; }

@media (max-width: 760px) {
    .history-hero { min-height: 0; }
    .history-hero-with-photo, .history-topic-grid, .history-editorial-with-image { grid-template-columns: minmax(0, 1fr); }
    .history-hero-photo { min-height: 0; aspect-ratio: 4 / 3; }
    .history-hero-photo img { object-position: center 18%; }
    .history-topic { min-height: 0; }
}

@media (forced-colors: active) {
    .history-hero, .history-topic, .history-editorial { background: Canvas; color: CanvasText; border: 1px solid CanvasText; }
    .history-topic[data-practice] { background: Canvas; }
    .history-practice-mark { display: none; }
    .history-hero p { color: CanvasText; }
}
