/* Sized in rem throughout (root font = --font-size-base, values are
   px-at-12 ÷ 12), so the Display panel's TEXT SIZE scales the whole
   surface, not just its type. Hairlines stay px. */

.clock {
    display: contents;
}

.clock-bar-widget {
    height: 100%;
    padding: 0 0.7292rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--color-foreground);
    cursor: pointer;
}

.bar[data-position="left"] .clock-bar-widget,
.bar[data-position="right"] .clock-bar-widget {
    height: auto;
    width: 100%;
    padding: 0.625rem 0;
    flex-direction: column;
    gap: 0.1667rem;
}

.clock-bar-widget[aria-expanded="true"] .clock-line {
    text-decoration: underline;
    text-underline-offset: 0.3333rem;
}

/* ---- Calendar panel ---------------------------------------------- */

.clock-panel {
    position: fixed;
    z-index: 150;
    width: 46.6667rem;
    max-width: calc(var(--viewport-w) - 16px);
    /* Never taller than the space beside the bar — the panel scrolls
       inside instead of running off screen (upstream wraps the
       calendar in a Flickable for the same reason). */
    max-height: calc(var(--viewport-h) - var(--bar-height) - 10px);
    overflow-y: auto;
    padding: 2.1667rem 0 1.5rem;
    background: var(--color-background);
    border: var(--border-width) solid var(--color-accent);
    border-radius: var(--radius);
    color: var(--color-foreground);
}

html[data-bar-position="left"] .clock-panel,
html[data-bar-position="right"] .clock-panel {
    max-height: calc(var(--viewport-h) - 10px);
}

html[data-bar-position="top"] .clock-panel {
    top: calc(var(--bar-height) + 5px);
    left: 50%;
    transform: translateX(-50%);
}

html[data-bar-position="bottom"] .clock-panel {
    bottom: calc(var(--bar-height) + 5px);
    left: 50%;
    transform: translateX(-50%);
}

html[data-bar-position="left"] .clock-panel {
    left: calc(var(--bar-size-vertical) + 5px);
    top: 50%;
    transform: translateY(-50%);
}

html[data-bar-position="right"] .clock-panel {
    right: calc(var(--bar-size-vertical) + 5px);
    top: 50%;
    transform: translateY(-50%);
}

/* Everything inside shares the grid's width, so the rails and the nav
   read as the panel's full-width rules rather than clusters floating in
   space. */
.clock-panel-content {
    width: 35.5rem;
    max-width: calc(100% - 24px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.6667rem;
}

/* ---- Hero: today, centered. Once the view has stepped away it is
   also the way home. */

.clock-hero {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 1.8333rem;
    margin-bottom: 0.8333rem;
}

.clock-hero-glyph {
    font-size: 4rem;
    line-height: 1;
}

.clock-hero-date {
    font-size: 4.3333rem;
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
}

.clock-hero-link {
    cursor: pointer;
}

.clock-hero-link:hover {
    color: var(--color-accent);
}

/* ---- Progress rails: the year, and — once a birth year is given —
   the memento mori below it. */

.clock-rail,
.clock-life-edit {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 1.8333rem;
}

.clock-rail-label {
    flex: none;
    font-size: 0.9167rem;
    letter-spacing: 0.08em;
    color: color-mix(in srgb, var(--color-foreground) 65%, transparent);
}

.clock-rail-percent {
    flex: none;
    font-size: 0.9167rem;
}

.clock-rail-track {
    flex: 1;
    height: 0.5rem;
    background: color-mix(in srgb, var(--color-foreground) 12%, transparent);
    border-radius: var(--radius);
    overflow: hidden;
}

.clock-rail-fill {
    display: block;
    height: 100%;
    background: var(--color-accent);
    transition: width 160ms ease-out;
}

.clock-life-edit {
    justify-content: center;
}

.clock-input {
    width: 5.3333rem;
    padding: 0.1667rem 0.5rem;
    background: color-mix(in srgb, var(--color-foreground) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-foreground) 25%, transparent);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--color-foreground);
}

.clock-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* ---- Month grid: week numbers down a gutter on the left, then the
   seven day columns. Always six rows, so the panel is exactly as tall
   in February as it is in August. */

.clock-grid {
    margin-top: 1.1667rem;
    display: grid;
    grid-template-columns: 2.6667rem 1.1667rem repeat(7, 1fr);
    gap: 0.25rem 0.1667rem;
    align-items: stretch;
}

.clock-wk-toggle,
.clock-dow {
    height: 1.3333rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8333rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.clock-dow {
    color: color-mix(in srgb, var(--color-foreground) 65%, transparent);
}

.clock-wk-toggle {
    padding: 0;
    border: none;
    background: none;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    color: color-mix(in srgb, var(--color-foreground) 53%, transparent);
    cursor: pointer;
}

.clock-wk-toggle:hover {
    background: color-mix(in srgb, var(--color-foreground) 8%, transparent);
    color: var(--color-accent);
}

.clock-wk {
    height: 2.8333rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8333rem;
    color: color-mix(in srgb, var(--color-foreground) 53%, transparent);
}

/* Hairline down the gutter, drawn only beside the day rows so it does
   not cut through the header band; each cell reaches up across the row
   gap so the segments join into one rule. */
.clock-gutter-rule {
    position: relative;
}

.clock-gutter-rule::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -0.25rem;
    bottom: 0;
    width: 1px;
    background: color-mix(in srgb, var(--color-foreground) 10%, transparent);
}

.clock-dow + .clock-wk + .clock-gutter-rule::before {
    top: 0;
}

.clock-day {
    height: 2.8333rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.0833rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
}

.clock-day-weekend {
    color: color-mix(in srgb, var(--color-foreground) 69%, transparent);
}

.clock-day-out {
    color: color-mix(in srgb, var(--color-foreground) 45%, transparent);
}

/* Today is outlined, not filled: a lit-up block shouts over a grid this
   quiet. */
.clock-day-today {
    border-color: color-mix(in srgb, var(--color-foreground) 60%, transparent);
    font-weight: 700;
}

/* ---- Month stepping, spanning the grid it drives. */

.clock-nav {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.clock-nav-button {
    margin: 0 -0.5rem;
    padding: 0.3333rem 0.5rem;
    border: none;
    background: none;
    font-family: var(--font-mono);
    font-size: 1.1667rem;
    color: var(--color-foreground);
    cursor: pointer;
}

.clock-nav-button:hover {
    color: var(--color-accent);
}

.clock-nav-label {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    letter-spacing: 0.08em;
    color: color-mix(in srgb, var(--color-foreground) 71%, transparent);
}

.clock-panel[data-mode="zones"] .clock-panel-content {
    display: none;
}

.clock-zones {
    width: 35.5rem;
    max-width: calc(100% - 24px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.6667rem;
    padding: 0.6667rem 0;
}

.clock-zone-search {
    width: 100%;
}

.clock-zone-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1667rem;
    overflow-y: auto;
}

.clock-zone-row {
    padding: 0.3333rem 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
}

.clock-zone-row:hover {
    background: color-mix(in srgb, var(--color-foreground) 10%, transparent);
}

.clock-zone-row-active {
    color: var(--color-accent);
}
