/*
Rules pages of the seven games.
Layout ranges: phone up to 600px, tablet 601-950px, desktop from 951px.
Same frame, reading column, text size and background as the legal pages (legal.css).
*/

/* Matches the bottom edge of the darkened background photo (visible as a band on phones while the browser bar hides) */
html {
    background-color: #292929;
}

.background-img {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    filter: brightness(40%);
}

/*-------------------
---------------------
---CONTENT---
---------------------
-------------------*/

/* Frame: 32px side margins, at most 1200px wide */
.content-container {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(calc(100% - 64px), 1200px);
    /* Starts right below the 80px header */
    margin: 5rem auto 0;
    z-index: 1;
}

/*-------------------
---TITLE: game logo beside a white sticker---
-------------------*/

/* --logo sets the size of the whole title block: the game name (logo / 4.2) and all spacing follow it, so the
   proportions are the same at every size. Gap between logo and name: logo / 2.8. Space above (to the header) is a bit
   bigger and space below (to "Objective") a bit smaller, because the left-aligned heading makes the gap below look larger. */
.title-container {
    --logo: 112px;
    width: 100%;
    margin: calc(var(--logo) / 2.45) auto calc(var(--logo) / 3.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--logo) / 2.8);
    isolation: isolate;
}

.logo-container {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    margin: 0;
    transform: rotate(-5deg);
    /* Shown by game-rules.js once the logo has loaded */
    visibility: hidden;
}

.logo-container.is-ready {
    visibility: visible;
}

a.logo-container:focus-visible {
    outline: 2px solid white;
    outline-offset: 7px;
    border-radius: 50%;
}

/* Soft light behind the logo */
.logo-container::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: -30%;
    background: radial-gradient(ellipse, #ffffff20, transparent 65%);
    pointer-events: none;
}

/* Border and 3D edge are worked out from the logo size, so they keep their proportions at every size */
.game-logo {
    display: block;
    box-sizing: border-box;
    width: var(--logo);
    height: auto;
    aspect-ratio: 1;
    border: calc(var(--logo) / 32) solid white;
    border-radius: 50%;
    background: white;
    box-shadow: 0 calc(var(--logo) / 25.6) 0 #ddd, 0 calc(var(--logo) / 12.8) 0 black, 0 calc(var(--logo) / 8) calc(var(--logo) / 5.33) #0006;
}

.title-container h1 {
    min-width: 0;
    margin: 0;
    /* Padding, corners and shadow in em: they scale with the text size, so the sticker keeps its proportions */
    padding: .33em .56em;
    border: 2px solid black;
    border-radius: .14em;
    background: white;
    color: black;
    box-shadow: .15em .15em 0 black;
    font-size: calc(var(--logo) / 4.2);
    font-weight: 800;
    letter-spacing: .02em;
    text-align: center;
    text-transform: uppercase;
    overflow-wrap: break-word;
    transform: rotate(1.5deg);
}

/*-------------------
---TEXT---
-------------------*/

/* Reading column: at most 680px, centred (about 85-90 characters per line) */
.background-text-container {
    margin: 0 auto;
    width: min(100%, 680px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.text-container {
    width: 100%;
    margin: 0 0 1.75rem;
    font-size: 1.0625rem;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

section {
    box-sizing: border-box;
    width: 100%;
    margin-bottom: 2rem;
    padding: 0;
    counter-reset: section;
}

/* "Objective" / "Rules" */
h2 {
    font-size: 1.5rem;
    line-height: 1.2;
    text-transform: uppercase;
    margin: 1em 0 0.5em;
}

/* The space above the first heading comes from the title block */
.text-container > section:first-child > h2:first-child {
    margin-top: 0;
}

/* Intro text: flush with its heading, same spacing as the legal pages */
p {
    box-sizing: border-box;
    width: 100%;
    margin: 0 0 0.75em;
    padding-inline-start: 0;
}

/* Section lists start flush with the heading; only the rules inside are indented (below) */
ol {
    counter-reset: subsection;
    list-style: none;
    color: white;
    padding-inline-start: 0;
}

/* Numbered section titles: "1. Format" */
.rules-title {
    counter-increment: section;
    counter-reset: subsection;
    font-size: 1.25rem;
    line-height: 1.3;
    margin: 1em 0 0.5em;
}

.rules-title::before {
    content: counter(section) ". ";
}

/* Nested lists belong to their parent rule and keep the body text size.
   The rules (1.1., 1.2. ...) sit 16px in from their section title (1. Format). */
.rules-title > ol {
    /* Same gap below the section title as between two rules */
    margin-top: .5em;
    padding-inline-start: 1rem;
    font-size: 1.0625rem;
    font-weight: 400;
    line-height: 1.5;
}

/* Single rules: "1.1. ..." */
.rules {
    counter-increment: subsection;
    display: flex;
    color: white;
    margin: 0 0 0.5em;
}

.rules::before {
    content: counter(section) "." counter(subsection) ". ";
    color: white;
    margin-right: 0.5em;
}

.rule-content {
    min-width: 0;
    flex: 1;
}

ul {
    list-style-type: "- ";
    margin: 0 0 0.5em;
    padding-inline-start: 2.5em;
}

/* Bullet points inside a rule: small indent so they read as part of that rule */
.rule-content ul {
    margin: .5em 0 0;
    padding-inline-start: 1em;
}

/* Tablet */
@media (max-width: 950px) {
    .title-container {
        --logo: 100px;
    }
}

/* Phone */
@media (max-width: 600px) {
    /* Logo and name stay side by side; below about 500px wide both shrink a little so the longest name fits */
    .title-container {
        --logo: clamp(56px, 18vw, 88px);
        /* A touch more space above and below than on larger screens (same 4:3 balance) */
        margin: calc(var(--logo) / 2.15) auto calc(var(--logo) / 2.9);
    }

    .text-container {
        margin-bottom: .75rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .rules-title {
        font-size: 1.125rem;
    }
}
