/* On This Day -- Decades of Leonardo (Story 5622). One card per past year for
   one calendar day; quiet years are a thin gray line. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: #F2F0EA; color: #222;
    font-family: "Segoe UI", system-ui, sans-serif; }

/* Full-height shell: only .otd-body scrolls, so the injected icon band, the
   header and the day bar stay pinned at the top. */
.page-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#lwIconBand, .ct-header, .otd-daybar, .otd-tools { flex: 0 0 auto; }

.ct-header {
    background: #3C3C3C; color: #fff; padding: 10px 16px;
    display: flex; align-items: center; gap: 12px;
}
.ct-header h1 { margin: 0; font-size: 14pt; font-weight: 600; flex: 1; }
.ct-header button {
    color: #fff; background: #4F46E5; border: none; border-radius: 4px;
    padding: 7px 14px; font: inherit; font-size: 13px; cursor: pointer;
}

/* The day: big, with an arrow each side. */
.otd-daybar {
    display: flex; align-items: center; gap: 10px;
    background: #FFFDF8; border-bottom: 1px solid #E4DFD2; padding: 10px 12px;
}
.otd-arrow {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 22px;
    border: 1px solid #D8D2C2; background: #fff; color: #5A4E2E;
    font-size: 16px; cursor: pointer;
}
.otd-arrow:active { background: #F1ECDF; }
.otd-day { flex: 1 1 auto; min-width: 0; text-align: center; }
.otd-day-label { font-size: 22px; font-weight: 700; color: #3B3320; }
.otd-day-sub { font-size: 12px; color: #6B6455; margin-top: 2px; }

.otd-tools {
    display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
    padding: 8px 12px; background: #FFFDF8; border-bottom: 1px solid #E4DFD2;
}
.otd-today {
    border: 1px solid #D8D2C2; background: #fff; color: #3B3320; border-radius: 16px;
    padding: 6px 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.otd-goto { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #5A4E2E; }
.otd-goto input[type="date"] {
    font: inherit; font-size: 13px; padding: 4px 6px;
    border: 1px solid #D8D2C2; border-radius: 6px; background: #fff; color: #222;
}

.otd-body { flex: 1; overflow: auto; padding: 14px 12px 24px; }
.otd-years { max-width: 760px; margin: 0 auto; }
.otd-loading, .otd-error { padding: 24px 8px; color: #6B6455; text-align: center; }
.otd-error { color: #9F1239; }

/* A year with memories. */
.otd-card {
    background: #fff; border: 1px solid #E4DFD2; border-radius: 12px;
    padding: 12px 14px 10px; margin-bottom: 12px;
    box-shadow: 0 2px 6px rgba(60, 50, 20, .06);
}
.otd-card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.otd-year { font-size: 24px; font-weight: 800; color: #3B3320; letter-spacing: -0.5px; }
.otd-ago { font-size: 13px; color: #6B6455; flex: 1 1 auto; }
.otd-reach {
    font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 10px;
    background: #FEF3C7; color: #92400E;
}
.otd-reach.exact { background: #DCFCE7; color: #166534; }

.otd-src { margin-top: 10px; }
.otd-src-label {
    font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: #8A7F66; margin-bottom: 3px;
}
.otd-item { display: block; padding: 5px 0; border-top: 1px solid #F1ECDF; }
.otd-src-label + .otd-item { border-top: none; }
.otd-item-title { display: block; font-size: 15px; color: #222; line-height: 1.35; overflow-wrap: anywhere; }
.otd-item-meta { display: block; font-size: 12px; color: #6B6455; margin-top: 2px; }
.otd-off { color: #92400E; }
.otd-exact { color: #166534; }
.otd-more { display: block; font-size: 12px; color: #8A7F66; padding-top: 3px; }

/* Every memory is a button that opens the detail modal: a full-width row, no button chrome. */
.otd-tap {
    margin: 0; border-left: 0; border-right: 0; border-bottom: 0; background: none;
    text-align: left; font: inherit; color: inherit; cursor: pointer; text-decoration: none;
    border-radius: 6px; padding-left: 6px; padding-right: 6px; margin-left: -6px; width: calc(100% + 12px);
    -webkit-tap-highlight-color: transparent;
}
.otd-tap:hover { background: #FBF8F0; }
.otd-tap:active { background: #F1ECDF; }
.otd-tap .otd-item-title { color: #1D4ED8; }
.otd-more.otd-tap { border-top: 0; color: #1D4ED8; }

/* The detail modal. Closed only by Close or Escape -- never a tap on the backdrop. */
.otd-modal-back {
    display: none; position: fixed; inset: 0; z-index: 9000;
    background: rgba(30, 25, 10, .45);
    align-items: center; justify-content: center; padding: 16px;
}
.otd-modal-back.open { display: flex; }
.otd-modal {
    display: flex; flex-direction: column; width: 100%; max-width: 560px;
    max-height: 88vh; max-height: 88dvh;
    background: #fff; border-radius: 14px; overflow: hidden;
    box-shadow: 0 12px 40px rgba(30, 25, 10, .3);
}
.otd-modal-head { flex: 0 0 auto; padding: 14px 16px 10px; background: #FFFDF8; border-bottom: 1px solid #E4DFD2; }
.otd-modal-kicker {
    font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #8A7F66;
}
.otd-modal-title {
    font-size: 19px; font-weight: 700; color: #3B3320; line-height: 1.3; margin-top: 3px;
    overflow-wrap: anywhere;
}
.otd-modal-when { font-size: 13px; color: #6B6455; margin-top: 5px; }
.otd-modal-body { flex: 1 1 auto; overflow: auto; padding: 12px 16px; }
.otd-modal-detail { font-size: 14px; color: #5A4E2E; margin-bottom: 10px; }
.otd-modal-note { font-size: 13px; color: #8A7F66; padding: 6px 0; }
.otd-modal-body .otd-loading, .otd-modal-body .otd-error { padding: 14px 4px; }
.otd-fields {
    display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px;
    font-size: 14px; margin-bottom: 8px;
}
.otd-field { display: contents; }
.otd-field-label { font-size: 12px; font-weight: 600; color: #8A7F66; padding-top: 1px; }
.otd-field-value { color: #222; overflow-wrap: anywhere; }
.otd-field-long { margin-top: 12px; }
.otd-field-long .otd-field-label { text-transform: uppercase; letter-spacing: .05em; font-size: 11px; margin-bottom: 4px; }
.otd-field-text {
    font-size: 14px; color: #222; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere;
    background: #FBF8F0; border: 1px solid #F1ECDF; border-radius: 8px; padding: 8px 10px;
}
.otd-modal-foot {
    flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-top: 1px solid #E4DFD2; background: #FFFDF8;
}
.otd-modal-gap { flex: 1 1 auto; }
.otd-btn {
    border: 1px solid #D8D2C2; background: #fff; color: #3B3320; border-radius: 6px;
    padding: 8px 16px; font: inherit; font-size: 14px; cursor: pointer; text-decoration: none;
}
.otd-btn.primary { background: #4F46E5; border-color: #4F46E5; color: #fff; }

/* Quiet years: one thin line, runs merged. */
.otd-quiet {
    font-size: 12px; color: #9A927F; padding: 6px 4px 10px;
    border-left: 3px solid #E4DFD2; margin: 0 0 10px 6px; padding-left: 10px;
}

@media (min-width: 700px) {
    .otd-item-title { font-size: 15px; }
    .otd-card { padding: 14px 18px 12px; }
}
