/* css/perilTimeline.css
 *
 * PerilGuard Event Timeline (includes/layers/perilTimeline.js): warning bars
 * over the loop's time range, in a panel along the bottom of the map between
 * the left-hand panels and the hail scale. Same semi-transparent blue as the
 * other HailTracker panels (indexDesktop.css). Desktop only: loaded at every
 * width so it can hide the timeline (and its dropdown item) on phones.
 */

.ptl-panel {
    --ptl-label-w: 222px;
    --ptl-lane-w: 76px;
    --ptl-gap: 10px;
    --ptl-accent: rgb(229, 132, 17);
    --ptl-divider: rgba(255, 255, 255, 0.10);
    /* the Map view only switch is a .pgs-switch (css/perilGuardSettings.css) */
    --pgs-field-bg: rgba(29, 52, 76, 0.55);
    --pgs-field-border: rgba(255, 255, 255, 0.18);
    --pgs-accent: rgb(229, 132, 17);

    position: fixed;
    left: 350px;
    right: 110px;
    bottom: 25px;
    z-index: 6;
    display: none;
    flex-direction: column;
    max-height: 42vh;
    overflow: hidden;
    background: rgba(44, 66, 94, 0.75);
    border: 1px solid rgba(44, 66, 94, 0.69);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(6.6px);
    -webkit-backdrop-filter: blur(6.6px);
    color: #ffffff;
    font: 12px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    text-align: left;
}

.ptl-panel.open {
    display: flex;
}

/* Widths include padding, so the bars line up with the time axis */
.ptl-panel *,
.ptl-tip * {
    box-sizing: border-box;
}

/* --- Header (drags the panel; double-click puts it back) --- */
.ptl-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 16px;
    border-bottom: 1px solid var(--ptl-divider);
    cursor: move;
    user-select: none;
}

/* Either side edge resizes it (perilTimeline.js) */
.ptl-resize {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 4;
    width: 6px;
    cursor: ew-resize;
    transition: background .15s ease;
}

.ptl-resize-left {
    left: 0;
}

.ptl-resize-right {
    right: 0;
}

.ptl-resize:hover {
    background: rgba(229, 132, 17, 0.45);
}

.ptl-panel.collapsed .ptl-header {
    border-bottom: none;
}

.ptl-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}

/* Prev Day / range / Next Day */
.ptl-dates {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ptl-range {
    opacity: .8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.ptl-day {
    flex: 0 0 auto;
    padding: 2px 9px;
    font: 600 11px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #ffffff;
    white-space: nowrap;
    background: var(--pgs-field-bg);
    border: 1px solid var(--pgs-field-border);
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}

.ptl-day i {
    font-size: 9px;
}

.ptl-day:hover:not(:disabled) {
    background: var(--ptl-accent);
    border-color: var(--ptl-accent);
}

/* No data that day (or a change is loading) */
.ptl-day:disabled {
    opacity: .35;
    cursor: default;
}

.ptl-status {
    color: var(--ptl-accent);
    white-space: nowrap;
}

.ptl-viewonly {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.ptl-collapse {
    padding: 0 4px;
    color: #ffffff;
    background: none;
    border: none;
    cursor: pointer;
    opacity: .75;
}

.ptl-collapse i {
    transition: transform .15s ease;
}

.ptl-panel.collapsed .ptl-collapse i {
    transform: rotate(180deg);
}

.ptl-close {
    cursor: pointer;
    font-size: 19px;
    line-height: 1;
    opacity: .7;
    padding: 0 2px;
}

.ptl-collapse:hover,
.ptl-close:hover {
    color: var(--ptl-accent);
    opacity: 1;
}

/* --- Body: time axis, then the lanes --- */
/* The right margin keeps its scrollbar clear of the resize edge */
.ptl-scroll {
    flex: 1 1 auto;
    min-height: 0;
    margin-right: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 0 8px;
}

.ptl-panel.collapsed .ptl-scroll {
    display: none;
}

.ptl-grid {
    position: relative;
    user-select: none;
}

.ptl-message {
    padding: 14px 16px;
    opacity: .8;
}

.ptl-axis-row {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    height: 20px;
    background: rgba(44, 66, 94, 0.92);
}

.ptl-axis-spacer {
    flex: 0 0 var(--ptl-label-w);
}

.ptl-axis {
    position: relative;
    flex: 1 1 auto;
    margin: 0 var(--ptl-gap);
}

.ptl-axis-label {
    position: absolute;
    top: 4px;
    transform: translateX(-50%);
    font-size: 10.5px;
    opacity: .75;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ptl-axis-label.ptl-axis-day {
    font-weight: 700;
    opacity: 1;
}

.ptl-axis-label.ptl-axis-end {
    transform: translateX(-100%);
}

/* A lane per peril: its name on the left, its lines (or a message) beside it */
.ptl-lane {
    display: flex;
    margin: 3px 6px 0;
    border-radius: 8px;
}

.ptl-lane:nth-of-type(odd) {
    background: rgba(72, 102, 138, 0.30);
}

.ptl-lane:nth-of-type(even) {
    background: rgba(16, 32, 54, 0.30);
}

.ptl-lane-name {
    flex: 0 0 calc(var(--ptl-lane-w) - 6px);
    padding: 5px 0 5px 10px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    line-height: 1.2;
}

.ptl-lane-lines {
    flex: 1 1 auto;
    min-width: 0;
    padding: 2px 0;
}

.ptl-empty {
    padding: 3px 0 3px calc(var(--ptl-label-w) - var(--ptl-lane-w));
    font-style: italic;
    opacity: .6;
}

.ptl-line {
    display: flex;
    align-items: center;
    height: 18px;
}

.ptl-line-label {
    flex: 0 0 calc(var(--ptl-label-w) - var(--ptl-lane-w));
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding-right: 6px;
}

.ptl-line-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ptl-swatches {
    flex: 0 0 auto;
    display: inline-flex;
    gap: 2px;
}

.ptl-swatch {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

/* The bars: issue to cancellation/expiry, in the map's colour */
/* Lines up with the axis and .ptl-overlay: the lane's 6px side margin is
   taken off the right gap */
.ptl-track {
    position: relative;
    flex: 1 1 auto;
    height: 100%;
    margin: 0 calc(var(--ptl-gap) - 6px) 0 var(--ptl-gap);
    cursor: pointer;
}

.ptl-bar {
    position: absolute;
    top: 4px;
    height: 10px;
    min-width: 2px;
    background: var(--ptl-colour);
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

/* Clipped at the range edges: squared off with an arrow, it carries on */
.ptl-bar.ptl-before {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.ptl-bar.ptl-after {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.ptl-bar.ptl-before::before,
.ptl-bar.ptl-after::after {
    content: "";
    position: absolute;
    top: -1px;
    border-style: solid;
}

.ptl-bar.ptl-before::before {
    left: -6px;
    border-width: 6px 6px 6px 0;
    border-color: transparent var(--ptl-colour) transparent transparent;
}

.ptl-bar.ptl-after::after {
    right: -6px;
    border-width: 6px 0 6px 6px;
    border-color: transparent transparent transparent var(--ptl-colour);
}

/* An issue or update */
.ptl-tick {
    position: absolute;
    top: 2px;
    width: 2px;
    height: 14px;
    margin-left: -1px;
    background: rgba(13, 24, 38, 0.85);
    border-radius: 1px;
    pointer-events: none;
}

/* Over the tracks: hour lines and the loop's current frame */
.ptl-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--ptl-label-w) + var(--ptl-gap));
    right: var(--ptl-gap);
    pointer-events: none;
}

.ptl-gridline {
    position: absolute;
    top: 20px;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.07);
}

.ptl-gridline.ptl-gridline-day {
    background: rgba(255, 255, 255, 0.22);
}

.ptl-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 3;
    width: 2px;
    margin-left: -1px;
    background: var(--ptl-accent);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

.ptl-playhead::before {
    content: "";
    position: absolute;
    top: 0;
    left: -5px;
    border-style: solid;
    border-width: 7px 6px 0 6px;
    border-color: var(--ptl-accent) transparent transparent transparent;
}

/* --- The warnings on a line (hover; pinned by a click) --- */
.ptl-tip {
    position: fixed;
    z-index: 40;
    display: none;
    max-width: 440px;
    max-height: 45vh;
    overflow-y: auto;
    padding: 4px;
    background: rgba(29, 52, 76, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    color: #ffffff;
    font: 12px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    text-align: left;
    pointer-events: none;
}

.ptl-tip.pinned {
    pointer-events: auto;
}

.ptl-tip-head {
    padding: 4px 8px 5px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.ptl-tip-time {
    font-weight: 400;
    opacity: .75;
    margin-left: 4px;
}

.ptl-item {
    display: block;
    width: 100%;
    padding: 5px 8px;
    color: inherit;
    font: inherit;
    text-align: left;
    background: none;
    border: none;
    border-radius: 6px;
}

.ptl-tip.pinned .ptl-item {
    cursor: pointer;
}

.ptl-tip.pinned .ptl-item:hover,
.ptl-tip.pinned .ptl-item:focus-visible {
    background: rgba(41, 87, 123, 0.60);
    outline: none;
}

.ptl-item-title {
    display: block;
    font-weight: 600;
}

.ptl-item-meta {
    display: block;
    font-size: 11px;
    opacity: .75;
}

/* The Event Timeline item in the PerilGuard dropdown while it is open:
   highlighted like a button that is on (update_css_button in functions.js) */
.peril-guard-dropdown button.active {
    background-color: rgb(229, 132, 17);
    border-color: rgb(229, 132, 17);
}

@media only screen and (min-width: 933px) {

    /* Things along the bottom of the map sit above the timeline while it is
       docked there (moved elsewhere, they stay put) */
    body.peril-timeline-open.peril-timeline-docked .bottom-menu,
    body.peril-timeline-open.peril-timeline-docked #nearmap-container {
        bottom: calc(var(--peril-timeline-h, 0px) + 35px);
    }

    body.peril-timeline-open.peril-timeline-docked .ContourScale {
        margin-top: calc(100vh - 180px - var(--peril-timeline-h, 0px));
    }
}

/* --- Phones: no timeline --- */
@media only screen and (max-width: 932px) {

    .ptl-panel,
    .ptl-tip,
    .peril-guard-dropdown button[data-peril-menu="timeline"] {
        display: none !important;
    }
}