/* Flip Clock - A Free Design by Bryant Smith (bryantsmith.com)

   This template is a retro split-flap clock. The whole page sits on a
   warm cream "clock casing", and every digit or letter is a dark tile
   with a seam across the middle.

   The file is laid out in short sections. Look for the headings:

     PALETTE          - every colour used on the page, named once
     BASE             - body and page casing
     BANDS            - the tinted horizontal strips
     TILE             - the split-flap card (the heart of the page)
     FLIP ANIMATION   - the one-off flip as the tiles land
     MASTHEAD / MENU  - title and navigation
     CLOCK            - the big time display
     GRID             - the two-column section layout
     TEXT / LISTS     - body copy, journal board and steps
     FOOTER
     SMALL SCREENS / MOTION / PRINT
*/


/* ---- PALETTE ----
   Change a hex value here and it updates everywhere it is used. */

:root {
    --casing:      #f4efe3;   /* the clock body */
    --casing-low:  #e9e1d1;   /* a slightly shaded band */
    --desk:        #ddd3bf;   /* the surface behind the body */
    --line:        #cfc2a9;   /* thin rules and borders */
    --ink:         #2b2822;   /* main text */
    --muted:       #635b4e;   /* quiet text */
    --tile-top:    #34343c;   /* top half of a tile */
    --tile-bottom: #26262c;   /* bottom half of a tile */
    --tile-edge:   #131316;   /* tile outline and seam */
    --digit:       #f7f2e5;   /* the character on a tile */
    --accent:      #c05a1d;   /* burnt orange, used sparingly */
    --accent-soft: #e0954f;   /* the orange that reads on dark */
    --screen:      #1b1a1f;   /* the dark clock window */
}


/* ---- BASE ---- */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--desk);
    /* a faint vertical grain, made with a repeating gradient */
    background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.024) 1px, transparent 1px);
    background-size: 4px 100%;
    color: var(--ink);
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    padding: 48px 16px;
    text-align: center;               /* centres the casing on the desk */
}

#page {
    background: var(--casing);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow:
        inset 0 1px 0 #ffffff,
        0 1px 2px rgba(0, 0, 0, 0.08),
        0 26px 60px rgba(45, 35, 20, 0.22);
    margin: 0 auto;
    max-width: 900px;
    overflow: hidden;                 /* clips the bands to the rounded corners */
    text-align: left;
}


/* ---- BANDS ----
   The page is a stack of full-width tinted strips. */

.band {
    padding: 56px 64px;
}

.band--alt {
    background: var(--casing-low);
}

.band + .band {
    border-top: 1px solid var(--line);
}


/* ---- TILE ----
   One tile is one empty element. Its character lives in data-glyph.
   The ::before draws the top half, the ::after draws the bottom half,
   and both are clipped to 50% height so a seam appears in the middle.
   The little "notches" on each side are radial gradients on the tile. */

.tile {
    --surface: var(--casing);         /* colour that shows through the notches */
    position: relative;
    display: inline-block;
    width: 0.78em;
    height: 1.05em;
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    color: var(--digit);
    vertical-align: top;
    perspective: 500px;               /* gives the flip its depth */
    background-color: var(--tile-bottom);
    background-image:
        radial-gradient(circle at 0 50%, var(--surface) 0 0.08em, transparent 0.081em),
        radial-gradient(circle at 100% 50%, var(--surface) 0 0.08em, transparent 0.081em),
        linear-gradient(180deg, var(--tile-top) 0 50%, var(--tile-bottom) 50% 100%);
    border-radius: 7px;
    box-shadow:
        inset 0 0 0 1px var(--tile-edge),
        0 2px 0 rgba(0, 0, 0, 0.35);
}

.tile::before,
.tile::after {
    content: attr(data-glyph);        /* pulls the letter out of the HTML */
    position: absolute;
    left: 0;
    right: 0;
    height: 50%;
    display: flex;
    align-items: flex-end;            /* both halves line up at the seam */
    justify-content: center;
    overflow: hidden;
    line-height: 1.05em;              /* full tile height, so halves match */
}

.tile::before {
    top: 0;
    align-items: flex-start;          /* shows the TOP half of the glyph */
    border-radius: 7px 7px 0 0;
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 80%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.10);
    transform-origin: center bottom;
}

.tile::after {
    bottom: 0;
    border-radius: 0 0 7px 7px;
    box-shadow:
        inset 0 2px 3px rgba(0, 0, 0, 0.55),
        inset 0 -1px 0 rgba(255, 255, 255, 0.04);
    transform-origin: center top;
}

/* sizes: the base tile is for section letters, these are for the clock */

.tile--lg  { font-size: clamp(56px, 15vw, 104px); }
.tile--sm  { font-size: clamp(30px, 8vw, 52px); }
.tile--idx { color: var(--accent-soft); font-size: 13px; }

/* on a shaded band the notches should match that band */

.band--alt .tile { --surface: var(--casing-low); }


/* ---- FLIP ANIMATION ----
   As the page loads each half swings open into place, like a flap
   settling. --i staggers the tiles. Anyone who asks their system for
   less motion gets a still page (see the bottom of this file). */

@keyframes flap-top {
    from { transform: rotateX(-90deg); }
    to   { transform: rotateX(0deg); }
}

@keyframes flap-bottom {
    from { transform: rotateX(90deg); }
    to   { transform: rotateX(0deg); }
}

.tile::before {
    animation: flap-top 0.55s ease-out both;
    animation-delay: calc(var(--i, 0) * 70ms);
}

.tile::after {
    animation: flap-bottom 0.55s ease-out both;
    animation-delay: calc(var(--i, 0) * 70ms);
}


/* ---- MASTHEAD ---- */

.band--masthead {
    border-bottom: 1px solid var(--line);
    padding-bottom: 40px;
}

.kicker {
    color: var(--muted);
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

#masthead h1 {
    color: var(--ink);
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 54px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.1;
    margin-top: 14px;
}

.tagline {
    color: var(--muted);
    font-size: 16px;
    margin-top: 10px;
}


/* ---- MENU ---- */

#menu {
    margin-top: 26px;
}

#menu a,
#menu a:visited {
    background: var(--casing);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    display: inline-block;
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 12px;
    letter-spacing: 2px;
    margin: 0 8px 8px 0;
    padding: 9px 14px;
    text-decoration: none;
    text-transform: uppercase;
    transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

#menu a:hover,
#menu a:focus {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

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


/* ---- CLOCK ---- */

.band--hero {
    background: var(--casing-low);
    padding-bottom: 48px;
}

.display {
    background: var(--screen);
    border: 1px solid #0d0d10;
    border-radius: 12px;
    box-shadow:
        inset 0 2px 12px rgba(0, 0, 0, 0.75),
        0 18px 40px rgba(35, 25, 12, 0.28);
    padding: 24px 30px 30px;
}

.display__legend {
    border-bottom: 1px solid #2c2b31;
    color: #8b8578;
    display: flex;
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 10px;
    justify-content: space-between;
    letter-spacing: 2.5px;
    margin-bottom: 26px;
    padding-bottom: 12px;
    text-transform: uppercase;
}

.clock {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    justify-content: center;
}

.clock .tile { --surface: var(--screen); }

.pair {
    display: inline-flex;
}

.pair .tile + .tile {
    margin-left: 0.06em;
}

.clock__colon {
    color: var(--accent-soft);
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: clamp(34px, 9vw, 60px);
    font-weight: 700;
    line-height: 1;
    animation: blink 2.4s steps(1, end) infinite;
}

.clock__colon--sm {
    font-size: clamp(22px, 5vw, 34px);
}

@keyframes blink {
    0%, 70%      { opacity: 1; }
    71%, 100%    { opacity: 0.4; }
}

.clock__meridiem {
    align-self: center;
    color: var(--accent-soft);
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: clamp(14px, 3vw, 20px);
    font-weight: 700;
    letter-spacing: 2px;
}

.clock__date {
    color: #9a9486;
    display: flex;
    flex-wrap: wrap;
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 12px;
    justify-content: center;
    letter-spacing: 4px;
    margin-top: 26px;
    text-transform: uppercase;
}

.clock__date span + span::before {
    color: var(--accent-soft);
    content: "\00b7";
    margin: 0 14px;
}

.display__note {
    color: var(--muted);
    font-size: 13px;
    margin-top: 20px;
    text-align: center;
}


/* ---- GRID ----
   Each section is a label column beside a wider body column. It is a
   simple two-column CSS grid, not a centred single column. */

.band__grid {
    align-items: start;
    display: grid;
    gap: 44px;
    grid-template-columns: 210px 1fr;
}

.index {
    display: inline-flex;
    margin-bottom: 14px;
}

.index .tile + .tile {
    margin-left: 4px;
}

.board-title {
    line-height: 1;
}

.flapword {
    display: inline-flex;
    flex-wrap: wrap;
}

.flapword .tile + .tile {
    margin-left: 4px;
}

.band__hint {
    color: var(--muted);
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 11px;
    letter-spacing: 1px;
    line-height: 1.6;
    margin-top: 16px;
    text-transform: uppercase;
}


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

.band__body p {
    margin-bottom: 18px;
    max-width: 66ch;
}

.band__body p:last-child {
    margin-bottom: 0;
}

.lead {
    color: #3a352c;
    font-size: 19px;
    line-height: 1.6;
}

.band__body a,
.band__body a:visited {
    border-bottom: 1px solid rgba(192, 90, 29, 0.4);
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.band__body a:hover {
    border-bottom-color: #8f3f11;
    color: #8f3f11;
}

code {
    background: var(--casing-low);
    border: 1px solid var(--line);
    border-radius: 4px;
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 0.86em;
    padding: 1px 5px;
}

.band--alt code {
    background: var(--casing);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}


/* ---- BOARD LIST: the little timetable of notes ---- */

.boardlist {
    list-style: none;
    margin-top: 22px;
}

.boardlist li {
    align-items: baseline;
    border-bottom: 1px dashed var(--line);
    display: flex;
    gap: 16px;
    padding: 13px 0;
}

.boardlist li:first-child {
    border-top: 1px dashed var(--line);
}

.boardlist__time {
    background: var(--tile-top);
    border: 1px solid var(--tile-edge);
    border-bottom-color: #0b0b0d;
    border-radius: 5px;
    box-shadow: 0 2px 0 var(--tile-edge);
    color: var(--digit);
    flex: 0 0 auto;
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 5px 9px;
}

.boardlist__text {
    color: var(--ink);
}


/* ---- STEPS: the numbered how-to list ---- */

.steps {
    counter-reset: step;
    list-style: none;
    margin-top: 22px;
}

.steps li {
    padding: 0 0 22px 58px;
    position: relative;
}

.steps li::before {
    align-items: center;
    background: var(--tile-top);
    border: 1px solid var(--tile-edge);
    border-radius: 6px;
    box-shadow: 0 2px 0 var(--tile-edge);
    color: var(--accent-soft);
    content: counter(step, decimal-leading-zero);
    counter-increment: step;
    display: flex;
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 14px;
    font-weight: 700;
    height: 40px;
    justify-content: center;
    left: 0;
    position: absolute;
    top: 0;
    width: 40px;
}

/* a seam across the step number, so it reads as a tile too */

.steps li::after {
    background: #0b0b0d;
    content: "";
    height: 1px;
    left: 0;
    position: absolute;
    top: 20px;
    width: 40px;
}

.steps li strong {
    color: var(--ink);
}


/* ---- FOOTER ---- */

#footer {
    background: var(--casing-low);
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-family: Consolas, "Courier New", Courier, monospace;
    font-size: 10px;
    letter-spacing: 2px;
    padding: 26px 64px 34px;
    text-align: center;
    text-transform: uppercase;
}

#footer a,
#footer a:visited {
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    text-decoration: none;
}

#footer a:hover {
    border-bottom-color: var(--accent);
    color: var(--accent);
}


/* ---- SMALL SCREENS ---- */

@media (max-width: 640px) {
    body {
        padding: 20px 10px;
    }

    .band {
        padding: 36px 22px;
    }

    .band--masthead {
        padding: 34px 22px 26px;
    }

    .band--hero {
        padding: 30px 16px 36px;
    }

    #masthead h1 {
        font-size: 38px;
    }

    .display {
        padding: 18px 16px 22px;
    }

    .band__grid {
        gap: 22px;
        grid-template-columns: 1fr;
    }

    .clock {
        gap: 6px 8px;
    }

    .boardlist li {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    #footer {
        padding: 20px 22px 26px;
    }
}


/* ---- REDUCED MOTION ----
   If the visitor has asked their system for less animation, the tiles
   simply appear without flipping and the colon stops blinking. */

@media (prefers-reduced-motion: reduce) {
    .tile::before,
    .tile::after,
    .clock__colon {
        animation: none;
    }

    #menu a,
    .band__body a {
        transition: none;
    }
}


/* ---- PRINT ---- */

@media print {
    body {
        background: #ffffff;
        padding: 0;
    }

    #page {
        border: none;
        box-shadow: none;
        max-width: 100%;
    }

    .band,
    .band--alt,
    .band--hero,
    #footer {
        background: #ffffff;
    }

    #menu {
        display: none;
    }

    .display {
        background: #ffffff;
        border: 1px solid #999999;
        box-shadow: none;
    }

    .tile,
    .boardlist__time,
    .steps li::before {
        background: #ffffff;
        box-shadow: none;
    }

    .tile::before,
    .tile::after {
        color: #000000;
        text-shadow: none;
    }

    .clock__colon,
    .clock__meridiem,
    .clock__date,
    .display__legend {
        color: #000000;
    }
}
