/* Kupu o te Rā. Plain CSS: nesting and custom properties need no build step. */

/* Roboto Slab, for headings and quotes. One variable font file per character range covers both weights. */
@font-face {
    font-family: 'Roboto Slab';
    font-weight: 400 700;
    font-display: swap;
    src: url(https://fonts.gstatic.com/s/robotoslab/v24/BngMUXZYTXPIvIBgJJSb6ufD5qW54A.woff2) format('woff2');
    unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Roboto Slab';
    font-weight: 400 700;
    font-display: swap;
    src: url(https://fonts.gstatic.com/s/robotoslab/v24/BngMUXZYTXPIvIBgJJSb6ufN5qU.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --deep-dark-green: #002500;
    --dark-green: #003000;
    --green: #004400;
    --light-green: #006000;
    --bright-green: #00ff00;
    --text: #fff;
    --muted: #ddd;
    --link: #abf;
    --link-hover: #bcf;
    --table-border: #060;
    --table-heading: #651;
    --table-heading-border: #541;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --heading-font: 'Roboto Slab', serif;
    --line: 24px;
    --header-height: 70px;
    --radius: 4px;
    --panel-radius: 5px;
    --wide: 768px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-padding-top: calc(var(--header-height) + 10px);
    -webkit-text-size-adjust: 100%;
    /* Keeps the scrollbar's strip whether or not the page scrolls, so the header doesn't move sideways between pages. */
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    background: var(--dark-green);
    color: var(--text);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.428571;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    @media (max-width: 56.25em) { font-size: 16px; }
    @media (max-width: 43.75em) { font-size: 15px; }
}

::selection {
    color: var(--text);
    background: #009300;
}

/* Text */

/* Regular weight: the Web Forms site asked for 500 but only declared 400 and 700, so browsers showed 400. */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--heading-font);
    font-weight: 400;
    margin: var(--line) 0 calc(var(--line) / 2);

    &:first-child { margin-top: 0; }
}
h4, h5, h6 { margin-top: calc(var(--line) / 2); }

/* After "A More Modern Scale for Web Typography", starting from a 17px body. */
h1 { font-size: 2em; line-height: 1.25; }
h2 { font-size: 1.625em; line-height: 1.15384615; }
h3 { font-size: 1.375em; line-height: 1.13636364; }
h4 { font-size: 1.125em; line-height: 1.11111111; }
@media (min-width: 43.75em) {
    h1 { font-size: 2.5em; line-height: 1.125; }
    h2 { font-size: 2em; line-height: 1.25; }
    h3 { font-size: 1.5em; line-height: 1.25; }
    h4 { line-height: 1.22222222; }
}
@media (min-width: 56.25em) {
    h1 { font-size: 3em; line-height: 1.05; }
    h2 { font-size: 2.25em; line-height: 1.25; }
    h3 { font-size: 1.75em; line-height: 1.25; }
}

p { margin: 0 0 16px; }

a {
    color: var(--link);
    text-decoration: none;
    transition: color 0.15s linear, background-color 0.15s linear, border-color 0.15s linear;

    &:hover, &:focus { color: var(--link-hover); text-decoration: underline; }
}

/* Emphasis glows rather than slants: "the agent and the patient". */
em {
    font-style: normal;
    text-shadow: 2px 2px 7px #fc0;
}

strong, b { font-weight: 700; }

ul, ol {
    margin: 0 0 calc(var(--line) / 2);
}
main li {
    margin-bottom: 15px;

    &:last-child { margin-bottom: 0; }
}

blockquote {
    margin: 0 0 var(--line);
    padding: calc(var(--line) / 2) var(--line);
}

img {
    vertical-align: middle;
    border: 0;
}

kbd {
    padding: 2px 4px;
    font-size: 90%;
    color: #fff;
    background-color: #333;
    border-radius: 3px;
}

hr {
    border: 0;
    border-top: 1px solid var(--muted);
    margin: var(--line) 0;
}

/* Te reo Māori and English example sentences, in the stored content. */
.QuoteMaori, .QuoteEnglish {
    font-family: var(--heading-font);
    font-style: normal;
}
.QuoteMaori {
    color: #afa;

    & strong { font-weight: 400; color: #6f6; text-shadow: 1px 1px 7px #fc0; }
}
.QuoteEnglish {
    color: #c9f;

    & strong { font-weight: 400; color: #93f; text-shadow: 1px 1px 7px #c6f; }
}
.Example { font-style: normal; }
span.isexample {
    font-size: 80%;
    color: #ccc;
    padding-left: 6pt;
}

.lead {
    margin-bottom: var(--line);
    font-size: 1.15em;
    font-weight: 300;
    line-height: 1.4;

    @media (min-width: 768px) { font-size: 1.5em; }
}
.large { font-size: 21px; }
.text-center { text-align: center; }
.img-responsive { display: block; max-width: 100%; height: auto; }

img.ha-o-te-ra {
    float: right;
    width: 297px;
    height: 509px;
    padding: 1em 0 2em 1em;

    @media (max-width: 767px) { width: 148px; height: 254px; }
}

/* Tables in the stored content: grammar charts. */
table {
    border-collapse: collapse;
    border-spacing: 0;
}
th { text-align: left; }
table.Standard {
    margin-bottom: 16px;

    & p { margin: 8px 0; }
    & td {
        border: 1px solid var(--table-border);
        padding: 0 7px;

        &.blank { border: none; }
        &.rightAlign { text-align: right; }
        &.center { text-align: center; }
    }
    & th {
        background-color: var(--table-heading);
        border: 1px solid var(--table-heading-border);
        font-weight: normal;
        padding: 0 7px;

        &.rightAlign { text-align: right; }
    }
}

/* Lists of kupu and sets. */
table.data {
    width: 100%;
    margin-bottom: var(--line);

    &.narrow { max-width: 480px; }
    & th, & td {
        padding: 8px;
        border-top: 1px solid var(--table-border);
        text-align: left;
        vertical-align: top;
    }
    & th { background-color: var(--table-heading); border-color: var(--table-heading-border); }
    & tbody tr:hover { background-color: var(--green); }
}

/* Te Kupu o te Wiki: a year's kupu with recordings. */
table.kupu-wiki {
    width: 100%;
    margin-bottom: var(--line);

    & th, & td {
        padding: 8px;
        border: 1px solid var(--table-border);
        vertical-align: middle;
    }
    & th { background-color: var(--table-heading); border-color: var(--table-heading-border); }
    & tbody tr:hover { background-color: var(--green); }
    & td.audio { width: 32px; padding: 8px 5px 4px; }
    & audio { width: 28px; height: 30px; }
}

/* Columns and blocks that only fit on wider screens. */
.wide-only {
    @media (max-width: 767px) { display: none; }
}

/* Layout */

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 15px;
}

#content {
    padding-top: calc(var(--header-height) + 25px);
    padding-bottom: 30px;

    @media (max-width: 767px) { padding-top: 60px; }
}

.footer-image {
    margin: 30px 0 0 13px;

    @media (max-width: 410px) { width: 100%; height: auto; margin-left: 0; }
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    flex: none;
}

/* Header and menus. Wide screens: a bar with dropdowns. Narrow: a burger button showing a list. */

.site-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1000;
    background: var(--deep-dark-green);
    border-bottom: 1px solid #000;
}

.site-header-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    min-height: 40px;

    @media (min-width: 768px) { min-height: var(--header-height); flex-wrap: nowrap; }
}

.home-link {
    display: flex;
    padding: 8px 15px 8px 5px;
    font-size: 25px;
    color: #872;

    &:hover, &:focus { color: var(--text); }
    & .icon { width: calc(28em / 24); } /* the home icon is broader than it is tall: a wharenui front with thick maihi */
}

.nav-toggle {
    margin-left: auto;
    padding: 6px 10px;
    font-size: 26px;
    line-height: 1;
    color: var(--text);
    background: none;
    border: 0;
    cursor: pointer;

    @media (min-width: 768px) { display: none; }
}

.site-nav {
    display: none;
    flex-basis: 100%;
    padding-bottom: 10px;

    &.open { display: block; }

    @media (min-width: 768px) {
        display: flex;
        flex: 1;
        align-items: stretch;
        align-self: stretch;
        padding-bottom: 0;
    }

    & ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    & .menu {
        @media (min-width: 768px) { display: flex; }
    }

    & details {
        position: relative;
        height: 100%;
    }

    & summary {
        display: flex;
        align-items: center;
        gap: 4px;
        height: 100%;
        padding: 15px 15px 15px 30px;
        border-bottom: 1px solid #4a4b50;
        color: var(--text);
        font-weight: 600;
        cursor: pointer;
        list-style: none;

        &::-webkit-details-marker { display: none; }
        &:hover, &:focus-visible { background: rgba(255, 255, 255, 0.1); }

        & .icon { font-size: 14px; transition: transform 0.15s; }

        @media (min-width: 768px) {
            padding: 0 10px;
            border-bottom: 0;
            font-size: 15px;
            font-weight: normal;
        }
    }

    & details[open] > summary {
        background: rgba(255, 255, 255, 0.2);

        & .icon { transform: rotate(180deg); }
    }

    /* The dropdown list itself. */
    & details > ul {
        padding: 0 0 0 30px;

        & a {
            display: block;
            padding: 12px 15px;
            color: var(--text);
            border-bottom: 1px solid #4a4b50;

            &:hover, &:focus { text-decoration: none; background: rgba(255, 255, 255, 0.1); }
        }

        @media (min-width: 768px) {
            position: absolute;
            top: 100%;
            left: 0;
            min-width: 200px;
            padding: 0;
            background: #fff;
            border-radius: 0 0 var(--radius) var(--radius);
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.25);
            overflow: hidden;

            & a {
                padding: 15px 20px;
                color: #333;
                font-size: 17px;
                border-bottom: 0;
                border-top: 1px solid #e4e9ec;
                white-space: nowrap;

                &:hover, &:focus { color: #000; background: #f5f5f5; }
            }
            & li:first-child a { border-top: 0; }
        }
    }

    & .language-menu {
        @media (min-width: 768px) {
            margin-left: auto;

            & > ul { left: auto; right: 0; min-width: 140px; }
        }
    }
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0 0 var(--line);
    padding: 0;
    font-size: 15px;

    & li { margin: 0; }
    & li + li::before {
        content: '>';
        margin: 0 6px 0 4px;
        color: var(--muted);
    }
    & a { color: var(--text); }
}

/* Panels and buttons */

/* A green panel with a bright border, named after greenstone. */
.pounamu {
    border: 1px solid var(--bright-green);
    background-color: var(--green);
    padding: 20px;
    border-radius: var(--panel-radius);

    & p { margin: 0; }
}

.btn {
    display: inline-block;
    padding: 6px 12px;
    font: inherit;
    font-weight: 500;
    line-height: 1.428571;
    text-align: center;
    color: var(--text);
    background: transparent;
    border: 1px solid #eee;
    border-radius: var(--radius);
    cursor: pointer;

    &:hover, &:focus {
        color: var(--text);
        text-decoration: none;
        border-color: var(--bright-green);
        background-color: var(--light-green);
    }
}

/* The main action on a page. */
.btn-primary {
    color: #000;
    background: #eee;
    border-color: #ddd;

    &:hover, &:focus { color: #000; background: #d4d4d4; border-color: #bbb; }
}

.buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Square buttons with a brand's colour and its icon. */
.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 47px;
    height: 47px;
    font-size: 26px;
    color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;

    &:hover, &:focus { color: #fff; filter: brightness(1.15); }

    &.facebook { background: #3b5998; }
    &.x { background: #000; border-color: #444; }
    &.linkedin { background: #007bb6; }
    &.rss, &.install { background: #ff6600; }
    &.instagram {
        border-color: #467fad;
        background: radial-gradient(circle farthest-corner at 35% 90%, #fec564, transparent 50%), radial-gradient(circle farthest-corner at 0 140%, #fec564, transparent 50%), radial-gradient(ellipse farthest-corner at 0 -25%, #5258cf, transparent 50%), radial-gradient(ellipse farthest-corner at 20% -50%, #5258cf, transparent 50%), radial-gradient(ellipse farthest-corner at 100% 0, #893dc2, transparent 50%), radial-gradient(ellipse farthest-corner at 60% -20%, #893dc2, transparent 50%), radial-gradient(ellipse farthest-corner at 100% 100%, #d9317a, transparent), linear-gradient(#6559ca, #bc318f 30%, #e33f5f 50%, #f77638 70%, #fec66d 100%);
    }
}

/* Kupu page */

.show-kupu {
    & audio { margin-top: 12px; }
    & .poster-link { display: inline-block; margin-top: 12px; }
}

/* Test */

.test {
    & .question-number { margin-top: var(--line); }
    & .question {
        font-size: 23px;
        margin: calc(var(--line) * 2) 0;

        & ul { padding-left: 1.5em; }
    }
    & .choices {
        border: 0;
        margin: 0 0 var(--line);
        padding: 0 0 0 var(--line);

        & label { display: block; margin-bottom: 10px; font-weight: 700; cursor: pointer; }
        & input { margin-right: 12px; }
    }
    & .preferences {
        font-size: 14px;

        & p { margin-bottom: 6px; }
        & label { display: block; margin: 0 0 6px var(--line); cursor: pointer; }
        & input { margin-right: 8px; }
    }
    & .results {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: var(--line);
    }
}

/* Home page */

.home {
    max-width: 720px;
    margin: 0 auto;

    & .todays-kupu {
        margin-bottom: var(--line);
        text-align: center;

        & h1 { font-size: 33px; font-weight: 700; }
        & h2 { font-family: var(--font); font-size: 17px; font-weight: normal; margin-bottom: 0; }
        & .current-kupu {
            margin: 12px 0 0;
            font-family: var(--heading-font);
            font-size: 33px;
            font-weight: 700;
        }
    }

    & .app-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 1rem;
        margin-bottom: 2rem;

        & .btn {
            width: 47%;

            @media (min-width: 580px) { width: 30%; }
        }
    }

    & .pounamu + .pounamu { margin-top: var(--line); }

    /* The offers to install the app: invisible but taking their space, one on top of the other, until site.js
       shows one, which fades in. */
    & .pwa-offer {
        display: grid;
        margin-top: var(--line);

        & > .pounamu {
            grid-area: 1 / 1;
            align-self: start;
            margin: 0;
            visibility: hidden;
            opacity: 0;
            transition: opacity 0.6s ease, visibility 0s 0.6s;
        }
        & > .shown { visibility: visible; opacity: 1; transition: opacity 0.6s ease; }

        @media (prefers-reduced-motion: reduce) { & > .pounamu { transition: none; } }
    }

    /* An icon or icons beside a paragraph. */
    & .with-icons {
        display: flex;
        align-items: center;
        gap: 10px;

        & > .social-icon { flex: none; }
        & .icons {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            flex: none;
        }
    }

    & .social .with-icons {
        @media (max-width: 579px) { flex-direction: column; align-items: flex-start; }
    }
}

@media print {
    .site-header, .footer-image { display: none; }
    body { background: #fff; color: #000; }
    #content { padding-top: 0; }
    blockquote { border: none; }
}

/* For signed-in kaitiaki: links to edit what the page shows. */
.kaitiaki-bar {
    position: fixed;
    right: 12px;
    bottom: 12px;
    z-index: 1000;
    display: flex;
    gap: 2px;
    font-size: 14px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);

    & a { padding: 6px 12px; color: #fff; background: var(--light-green); }
    & a:hover { background: #007a00; text-decoration: none; }

    @media print { display: none; }
}
