/*
Theme Name: El Gallo
Theme URI: https://elgallodecabanes.eu/
Author: Anonimo
Description: Tema editorial ligero para El ultimo secreto de El Gallo.
Version: 1.1.1
Requires at least: 6.5
Requires PHP: 8.1
Text Domain: el-gallo
*/

@font-face {
    font-family: "Source Serif 4";
    src: url("assets/fonts/source-serif-4-variable-roman.ttf") format("truetype");
    font-style: normal;
    font-weight: 200 900;
    font-display: swap;
}

@font-face {
    font-family: "Source Serif 4";
    src: url("assets/fonts/source-serif-4-variable-italic.ttf") format("truetype");
    font-style: italic;
    font-weight: 200 900;
    font-display: swap;
}

@font-face {
    font-family: Inter;
    src: url("assets/fonts/inter-variable.woff2") format("woff2");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --paper: #f3ebdd;
    --paper-deep: #e8ddca;
    --ink: #2c251f;
    --muted: #695d51;
    --line: #cdbda5;
    --accent: #743b32;
    --accent-strong: #5f2f28;
    --header-height: 76px;
    --reading-width: 680px;
    --media-width: 920px;
    color-scheme: light;
}

html[data-theme="night"] {
    --paper: #201c19;
    --paper-deep: #2a2420;
    --ink: #eee5d7;
    --muted: #bcae9d;
    --line: #55483e;
    --accent: #d59484;
    --accent-strong: #efaa99;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Source Serif 4", Georgia, serif;
    text-rendering: optimizeLegibility;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
    content: "";
    opacity: 0.045;
    pointer-events: none;
}

a {
    color: inherit;
    text-decoration-color: var(--accent);
    text-underline-offset: 0.18em;
}

a:hover {
    color: var(--accent);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1000;
    padding: 10px 14px;
    background: var(--ink);
    color: var(--paper);
    font: 600 14px/1 Inter, sans-serif;
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

.reading-progress {
    position: fixed;
    inset: 0 0 auto;
    z-index: 100;
    height: 3px;
    background: var(--line);
}

.reading-progress__bar {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
    transform-origin: left center;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: var(--header-height);
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--paper) 94%, transparent);
}

body.admin-bar .site-header {
    top: 32px;
}

.site-header__inner {
    display: flex;
    width: min(100% - 40px, 1240px);
    min-height: var(--header-height);
    margin: 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.site-brand {
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 18px;
    font-variant-caps: small-caps;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1.15;
    text-decoration: none;
}

.site-brand:hover {
    color: var(--ink);
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 22px;
    font: 500 14px/1 Inter, sans-serif;
}

.site-nav__link {
    padding-block: 8px;
    text-decoration: none;
}

.site-nav__link::after {
    display: block;
    width: 100%;
    height: 1px;
    margin-top: 5px;
    background: var(--accent);
    content: "";
    transform: scaleX(0);
    transition: transform 160ms ease;
}

.site-nav__link:hover::after,
.site-nav__link:focus-visible::after {
    transform: scaleX(1);
}

.icon-button {
    display: inline-grid;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    place-items: center;
}

.icon-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.icon-button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.6;
}

.chapter-shell {
    padding: clamp(72px, 9vw, 132px) 20px 96px;
}

.chapter-header,
.chapter-content,
.chapter-footer {
    width: min(100%, var(--reading-width));
    margin-inline: auto;
}

.chapter-part {
    margin: 0 0 24px;
    color: var(--accent);
    font: 650 12px/1.4 Inter, sans-serif;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.chapter-title {
    margin: 0;
    font-size: 66px;
    font-weight: 450;
    line-height: 1.02;
    text-wrap: balance;
}

.chapter-title__section,
.chapter-title__name {
    display: block;
}

.chapter-title__section {
    margin-bottom: 8px;
    font-size: 0.72em;
}

.chapter-meta {
    display: flex;
    margin: 28px 0 54px;
    color: var(--muted);
    font: 450 14px/1.5 Inter, sans-serif;
    gap: 0;
    flex-wrap: wrap;
}

.chapter-meta span {
    display: inline-flex;
    align-items: center;
}

.chapter-meta span + span::before {
    width: 1px;
    height: 18px;
    margin-inline: 18px;
    background: var(--line);
    content: "";
}

.chapter-divider {
    display: grid;
    margin-bottom: 54px;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 13px;
    color: var(--line);
}

.chapter-divider::before,
.chapter-divider::after {
    height: 1px;
    background: currentColor;
    content: "";
}

.chapter-divider svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: var(--accent);
    stroke-width: 1;
}

.chapter-content {
    font-size: 20px;
    line-height: 1.72;
}

.chapter-content p {
    margin: 0 0 1.38em;
    orphans: 3;
    widows: 3;
}

.chapter-content p:first-child::first-letter {
    float: left;
    margin: 0.08em 0.11em 0 0;
    color: var(--accent);
    font-size: 4.1em;
    font-weight: 500;
    line-height: 0.72;
}

.chapter-content em {
    color: var(--muted);
}

.chapter-figure {
    width: min(calc(100vw - 40px), var(--media-width));
    margin: clamp(58px, 8vw, 92px) 50% clamp(58px, 8vw, 92px);
    transform: translateX(-50%);
}

.chapter-figure--portrait {
    width: min(calc(100vw - 40px), 680px);
}

.chapter-figure img {
    display: block;
    width: 100%;
    height: auto;
    background: var(--paper-deep);
    filter: none;
}

.chapter-ending {
    margin-top: 0.5em !important;
    font-size: 1.16em;
    font-weight: 550;
}

.chapter-footer {
    padding-top: 28px;
}

.chapter-endmark {
    display: grid;
    margin: 56px 0;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    color: var(--line);
}

.chapter-endmark::before,
.chapter-endmark::after {
    height: 1px;
    background: currentColor;
    content: "";
}

.chapter-endmark span {
    width: 7px;
    height: 7px;
    border: 1px solid var(--accent);
    transform: rotate(45deg);
}

.chapter-navigation {
    display: grid;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    grid-template-columns: 1fr auto 1fr;
}

.chapter-navigation a,
.chapter-navigation__disabled {
    display: flex;
    min-height: 104px;
    padding: 20px 0;
    flex-direction: column;
    justify-content: center;
    text-decoration: none;
}

.chapter-navigation__next {
    text-align: right;
}

.chapter-navigation__index {
    padding-inline: 28px !important;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
    font: 600 12px/1 Inter, sans-serif;
    text-transform: uppercase;
}

.chapter-navigation__label {
    margin-bottom: 8px;
    color: var(--muted);
    font: 600 10px/1.2 Inter, sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chapter-navigation__title {
    font-size: 16px;
    line-height: 1.25;
}

.chapter-navigation__disabled {
    color: var(--muted);
    opacity: 0.62;
}

.index-page,
.standard-page {
    width: min(100% - 40px, 980px);
    margin: 0 auto;
    padding: 80px 0 120px;
}

.index-page {
    padding-top: 48px;
}

.index-page h1,
.standard-page h1 {
    margin: 0 0 48px;
    font-size: 72px;
    font-weight: 450;
    line-height: 1;
}

.index-intro {
    display: grid;
    margin-bottom: 52px;
    padding-bottom: 52px;
    border-bottom: 1px solid var(--line);
    grid-template-columns: minmax(150px, 210px) 1fr;
    align-items: end;
    gap: clamp(32px, 6vw, 72px);
}

.index-intro__cover {
    display: block;
    border: 1px solid color-mix(in srgb, var(--line) 76%, var(--ink));
    background: var(--paper-deep);
    box-shadow: 0 18px 42px rgb(31 24 18 / 16%);
}

.index-intro__cover img {
    display: block;
    width: 100%;
    height: auto;
}

.index-intro__heading p {
    margin: 0 0 12px;
    color: var(--accent);
    font: 650 12px/1.4 Inter, sans-serif;
    text-transform: uppercase;
}

.index-intro__heading h1 {
    margin: 0;
}

.chapter-list {
    border-top: 1px solid var(--line);
}

.chapter-list__item {
    display: grid;
    padding: 24px 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: 120px 1fr auto;
    align-items: baseline;
    gap: 24px;
}

.chapter-list__section,
.chapter-list__meta {
    color: var(--muted);
    font: 500 12px/1.4 Inter, sans-serif;
}

.chapter-list__title {
    font-size: 24px;
    text-decoration: none;
}

.chapter-list__item--unpublished .chapter-list__title,
.chapter-list__item--unpublished .chapter-list__section,
.chapter-list__item--unpublished .chapter-list__meta {
    color: var(--muted);
}

.chapter-list__item--unpublished .chapter-list__title {
    font-style: italic;
}

.cover-page {
    display: grid;
    min-height: calc(100svh - var(--header-height));
    padding: clamp(18px, 3.5vh, 34px) 20px clamp(28px, 5vh, 52px);
    place-items: center;
}

.cover-page__inner {
    display: grid;
    width: min(100%, 480px);
    justify-items: center;
    gap: clamp(20px, 3vh, 30px);
}

.book-cover {
    width: min(100%, 440px, calc(68svh * 0.6667));
    margin: 0;
    border: 1px solid color-mix(in srgb, var(--line) 72%, var(--ink));
    background: var(--paper-deep);
    box-shadow: 0 24px 62px rgb(31 24 18 / 20%);
}

.book-cover img {
    display: block;
    width: 100%;
    height: auto;
}

.cover-actions {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 14px 24px;
    flex-wrap: wrap;
    font: 600 13px/1.2 Inter, sans-serif;
}

.cover-actions a {
    min-height: 46px;
    padding: 14px 20px;
    text-align: center;
    text-decoration: none;
}

.cover-actions__primary {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--paper);
}

.cover-actions__primary:hover,
.cover-actions__primary:focus-visible {
    background: var(--accent-strong);
    color: var(--paper);
}

.cover-actions__secondary {
    border-bottom: 1px solid var(--accent);
}

.holding-page {
    display: grid;
    min-height: calc(100vh - var(--header-height));
    padding: 48px 20px;
    place-items: center;
}

.holding-page__inner {
    width: min(100%, 680px);
    text-align: center;
}

.holding-page__mark {
    width: 46px;
    height: 46px;
    margin: 0 auto 34px;
    border: 1px solid var(--accent);
    transform: rotate(45deg);
}

.holding-page h1 {
    margin: 0 0 20px;
    font-size: 78px;
    font-weight: 450;
    line-height: 1;
}

.holding-page p {
    margin: 0;
    color: var(--muted);
    font: 450 15px/1.6 Inter, sans-serif;
}

.site-footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font: 450 12px/1.6 Inter, sans-serif;
    text-align: center;
}

.site-footer__inner {
    width: min(100% - 40px, 920px);
    margin: 0 auto;
    padding: 28px 0 36px;
}

.site-footer p {
    margin: 0;
}

.site-footer__work {
    color: var(--ink);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 14px;
    font-variant-caps: small-caps;
    font-weight: 600;
}

.site-footer__rights {
    margin-top: 8px !important;
}

.site-footer__links {
    display: flex;
    margin-top: 12px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.site-footer__links a {
    overflow-wrap: anywhere;
}

.standard-page .chapter-content {
    width: min(100%, 720px);
    margin-inline: 0;
}

.standard-page .chapter-content p:first-child::first-letter {
    float: none;
    margin: 0;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
}

.standard-page .chapter-content h2 {
    margin: 2.2em 0 0.7em;
    font-size: 32px;
    font-weight: 500;
    line-height: 1.15;
}

.standard-page .chapter-content a {
    overflow-wrap: anywhere;
}

.screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 720px) {
    :root {
        --header-height: 70px;
    }

    .site-header__inner {
        width: min(100% - 28px, 1240px);
        gap: 12px;
    }

    .site-brand {
        max-width: 176px;
        font-size: 14px;
        letter-spacing: 0.06em;
    }

    .site-nav {
        gap: 12px;
        font-size: 13px;
    }

    .icon-button {
        width: 38px;
        height: 38px;
    }

    .chapter-shell {
        padding: 58px 20px 72px;
    }

    .chapter-part {
        margin-bottom: 22px;
        font-size: 10px;
        letter-spacing: 0.11em;
    }

    .chapter-title {
        font-size: 42px;
        line-height: 1.03;
    }

    .chapter-title__section {
        font-size: 0.68em;
    }

    .chapter-meta {
        margin: 26px 0 36px;
        flex-direction: column;
        gap: 8px;
        font-size: 13px;
    }

    .chapter-meta span + span::before {
        display: none;
    }

    .chapter-divider {
        margin-bottom: 38px;
    }

    .chapter-content {
        font-size: 18px;
        line-height: 1.7;
    }

    .chapter-content p {
        margin-bottom: 1.32em;
    }

    .chapter-figure {
        width: calc(100vw - 24px);
        margin-top: 52px;
        margin-bottom: 52px;
    }

    .chapter-figure--portrait {
        width: calc(100vw - 40px);
    }

    .chapter-navigation {
        grid-template-columns: 1fr 58px 1fr;
    }

    .chapter-navigation a,
    .chapter-navigation__disabled {
        min-height: 92px;
    }

    .chapter-navigation__index {
        padding-inline: 0 !important;
        align-items: center;
        font-size: 0;
    }

    .chapter-navigation__index::before {
        font-size: 18px;
        content: "≡";
    }

    .chapter-navigation__title {
        font-size: 14px;
    }

    .chapter-list__item {
        grid-template-columns: 1fr;
        gap: 7px;
    }

    .index-page {
        width: min(100% - 28px, 980px);
        padding-top: 28px;
    }

    .index-intro {
        margin-bottom: 36px;
        padding-bottom: 36px;
        grid-template-columns: minmax(92px, 116px) 1fr;
        gap: 22px;
    }

    .index-intro__heading p {
        font-size: 10px;
    }

    .index-page h1,
    .standard-page h1,
    .holding-page h1 {
        font-size: 46px;
    }

    .standard-page {
        width: min(100% - 40px, 980px);
        padding: 56px 0 80px;
    }

    .standard-page .chapter-content h2 {
        font-size: 27px;
    }

    .site-footer__inner {
        width: min(100% - 32px, 920px);
    }
}

@media (max-width: 782px) {
    body.admin-bar .site-header {
        top: 46px;
    }
}

@media (min-width: 721px) and (max-width: 980px) {
    .chapter-title {
        font-size: 56px;
    }

    .index-page h1,
    .standard-page h1,
    .holding-page h1 {
        font-size: 62px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
    }
}

@media (forced-colors: active) {
    .cover-actions__primary {
        border: 2px solid ButtonText;
    }
}
