/* A day's items, the assistant beside them, and the menu that adds to a day. */

.timeline { margin-top: var(--space-5); display: grid; }
.timeline-item,
.timeline-row,
.transport-row {
    min-height: 96px;
    display: grid;
    grid-template-columns: 72px 30px minmax(0, 1fr);
    align-items: start;
    position: relative;
}
/* The thread the markers hang on. */
.timeline-item::before,
.timeline-row::before,
.transport-row::before {
    content: "";
    position: absolute;
    left: 86px;
    top: 32px;
    bottom: -2px;
    border-left: 1px solid var(--line);
}
.timeline-item:last-child::before { display: none; }

.timeline-time {
    padding-top: var(--space-2);
    display: flex;
    flex-direction: column;
    text-align: right;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.timeline-time strong { font-size: var(--text-xs); font-weight: var(--weight-semi); }
.timeline-time span,
.timeline-time small {
    margin-top: 2px;
    color: var(--ink-3);
    font-size: var(--text-2xs);
}

/* The mark carries the drawing for its kind, so the left edge of a day can be
   read without reading any of the words. */
.timeline-marker {
    width: 28px;
    height: 28px;
    margin: var(--space-2) 0 0 1px;
    z-index: 1;
    display: grid;
    place-items: center;
    border-radius: var(--radius-full);
    background: var(--fern-tint);
    color: var(--fern);
    border: 3px solid var(--canvas);
}
.timeline-marker svg { display: block; }
.timeline-item.kind-stay .timeline-marker,
.stay-row .timeline-marker {
    background: var(--canvas-2);
    color: var(--ink-2);
}
.timeline-item.kind-drive .timeline-marker,
.drive-connection-row .timeline-marker {
    background: var(--canvas);
    color: var(--ink-3);
    border-style: dashed;
    border-width: 1px;
    border-color: var(--line-strong);
}
.timeline-item.kind-flight .timeline-marker,
.flight-row .timeline-marker {
    background: var(--calm-tint);
    color: var(--calm);
}

/* ------------------------------------------------------------------- cards */

.timeline-card,
.activity-card,
.transport-card {
    width: 100%;
    margin: 0 0 var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--paper);
    text-align: left;
    box-shadow: var(--shadow-1);
    transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-2) var(--ease),
                transform var(--dur-2) var(--ease);
}
.timeline-card:hover,
.activity-card:hover,
.transport-card:hover {
    border-color: var(--line-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-2);
}

/* A place is the substance of a day, so it is the only kind that gets a spine
   of colour. A stay and a drive are the connective tissue around it. */
.kind-place .timeline-card,
.timeline-card.kind-place { border-left: 3px solid var(--fern); }

/* Where the night is spent. It closes the day, so it is the one card that is
   filled rather than outlined - a block at the end of the run, not another
   thing in the middle of it. */
.kind-stay .timeline-card,
.timeline-card.kind-stay,
.activity-card.is-stay {
    border-color: var(--canvas-3);
    background: var(--canvas-2);
    box-shadow: none;
}
.kind-stay .timeline-card:hover,
.timeline-card.kind-stay:hover,
.activity-card.is-stay:hover {
    border-color: var(--ink-3);
    background: var(--canvas-2);
    box-shadow: none;
    transform: none;
}
.kind-stay .timeline-card h3,
.activity-card.is-stay h3 { color: var(--ink); }

.kind-drive .timeline-card,
.timeline-card.kind-drive,
.trip-workspace .drive-connection-row .transport-card {
    padding: var(--space-2) var(--space-4);
    border: 1px dashed var(--line-strong);
    border-left: 3px dashed var(--fern);
    background: transparent;
    box-shadow: none;
}
.kind-drive .timeline-card:hover,
.timeline-card.kind-drive:hover,
.trip-workspace .drive-connection-row .transport-card:hover {
    border-color: var(--fern);
    background: var(--fern-tint);
    box-shadow: none;
    transform: none;
}

.kind-flight .timeline-card,
.timeline-card.kind-flight,
.trip-workspace .flight-row .transport-card {
    border-left: 3px solid var(--calm);
    background: var(--paper);
}

.timeline-card-top,
.activity-header,
.transport-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
}

.kind-label,
.item-kind-label {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    color: var(--fern);
    background: var(--fern-tint);
    font-size: var(--text-2xs);
    font-weight: var(--weight-semi);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}
.kind-label.kind-stay,
.activity-card.is-stay .item-kind-label {
    color: var(--paper);
    background: var(--ink-2);
}
.kind-label.kind-flight,
.kind-flight .item-kind-label { color: var(--calm); background: var(--calm-tint); }

.kind-drive.timeline-item,
.drive-connection-row { min-height: 72px; }
.timeline-item.kind-drive .timeline-marker { outline: 3px solid var(--canvas); }

.booked-badge,
.status-badge {
    padding: 2px var(--space-2);
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-full);
    font-size: var(--text-2xs);
    font-weight: var(--weight-semi);
    background: var(--fern-tint);
    color: var(--fern);
}

.timeline-card h3 {
    margin: var(--space-2) 0 var(--space-1);
    font-size: var(--text-sm);
    letter-spacing: var(--tracking-tight);
    font-weight: var(--weight-semi);
    line-height: var(--leading-snug);
}
.kind-drive .timeline-card h3 { margin: var(--space-1) 0 0; font-size: var(--text-xs); }

.place-line,
.activity-meta,
.transport-meta {
    margin: 0;
    color: var(--ink-3);
    font-size: var(--text-xs);
}
.item-meta-row,
.activity-price {
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px solid var(--line);
    color: var(--ink-2);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
}
.activity-notes,
.transport-notes {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: var(--space-2) 0 0;
    color: var(--ink-2);
    font-size: var(--text-xs);
    line-height: var(--leading-normal);
}

/* --------------------------------------------------------- the assistant */
/* A column, not a drawer. See the note at the top of planner.css. */

.assistant-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--paper);
}
.assistant-header {
    flex: none;
    min-height: 56px;
    padding: var(--space-3) var(--space-4);
    display: grid;
    grid-template-columns: 32px 1fr 34px;
    align-items: center;
    gap: var(--space-3);
    border-bottom: 1px solid var(--line);
}
.assistant-header-copy { display: flex; flex-direction: column; min-width: 0; }
.assistant-header strong { font-size: var(--text-xs); font-weight: var(--weight-semi); }
.assistant-header small {
    color: var(--ink-3);
    font-size: var(--text-2xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai-orb { width: 32px; height: 32px; border-radius: var(--radius-md); }

.assistant-body {
    flex: 1;
    min-height: 0;
    padding: var(--space-4);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.assistant-transcript {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
}
.assistant-message {
    max-width: 100%;
    margin: 0;
    padding: var(--space-3);
    border-radius: var(--radius-md) var(--radius-md) var(--radius-md) var(--radius-sm);
    background: var(--fern-tint);
    color: var(--ink);
    font-size: var(--text-xs);
    line-height: var(--leading-normal);
    overflow-wrap: anywhere;
}
.assistant-turn { max-width: 92%; }
.assistant-turn.is-traveller {
    align-self: flex-end;
    border-radius: var(--radius-md) var(--radius-md) var(--radius-sm) var(--radius-md);
    border: 1px solid var(--line);
    background: var(--canvas);
    color: var(--ink);
}

.assistant-suggestions { display: grid; gap: var(--space-2); }
.assistant-suggestions button {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--paper);
    color: var(--ink-2);
    text-align: left;
    font-size: var(--text-xs);
    transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease),
                color var(--dur-1) var(--ease);
}
.assistant-suggestions button:hover {
    border-color: var(--fern);
    background: var(--fern-tint);
    color: var(--ink);
}

.assistant-composer {
    flex: none;
    margin: 0 var(--space-4);
    padding: var(--space-2);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: var(--space-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    background: var(--paper);
    transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.assistant-composer:focus-within {
    border-color: var(--fern);
    box-shadow: 0 0 0 3px var(--fern-tint-2);
}
.assistant-composer textarea {
    min-height: 44px;
    max-height: 148px;
    resize: none;
    border: 0;
    padding: var(--space-2);
    font-size: var(--text-xs);
    line-height: var(--leading-normal);
    background: transparent;
}
.assistant-composer textarea:focus { outline: none; }
.assistant-composer button {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: var(--radius-md);
    background: var(--fern);
    color: var(--ink-inverse);
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
}
.assistant-composer button:hover:not(:disabled) { background: var(--fern-hover); }
.assistant-composer button:disabled { opacity: 0.5; cursor: not-allowed; }

.assistant-footnote {
    flex: none;
    margin: var(--space-2) var(--space-4) var(--space-4);
    text-align: center;
    color: var(--ink-3);
    font-size: var(--text-2xs);
}

.mobile-assistant-fab { display: none; }

/* --------------------------------------------------------- add to a day */

.add-item.add-item-header {
    position: relative;
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: none;
}
.day-action-button {
    min-height: 34px;
    padding: 0 var(--space-3);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--paper);
    color: var(--ink);
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
}
.day-action-button:hover { border-color: var(--ink-3); background: var(--canvas); }
.add-item-menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    z-index: 30;
    width: min(300px, calc(100vw - var(--space-6)));
    padding: var(--space-1);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--paper);
    box-shadow: var(--shadow-3);
}
.add-item-header .add-item-button {
    width: 100%;
    min-height: 52px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2);
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    text-align: left;
}
.add-item-header .add-item-button:hover { background: var(--canvas); }
.add-item-menu-icon {
    width: 32px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--fern);
    background: var(--fern-tint);
}
.add-item-menu-copy { display: grid; gap: 1px; }
.add-item-menu-copy strong { font-size: var(--text-xs); font-weight: var(--weight-semi); }
.add-item-menu-copy small { color: var(--ink-3); font-size: var(--text-2xs); }
.add-item-ask-button {
    width: 100%;
    min-height: 40px;
    margin-top: var(--space-1);
    padding: 0 var(--space-3);
    display: flex;
    align-items: center;
    border-top: 1px solid var(--line);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
    background: transparent;
    color: var(--fern);
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
    text-align: left;
}
.add-item-ask-button:hover { background: var(--fern-tint); }

/* ------------------------------------------------------------- forecast */

.day-weather {
    margin: var(--space-2) 0 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
    font-size: var(--text-xs);
    color: var(--ink-2);
}
.day-weather strong {
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    background: var(--calm-tint);
    color: var(--calm);
    font-size: var(--text-2xs);
    font-weight: var(--weight-semi);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
}
.day-weather small { color: var(--ink-3); font-size: var(--text-2xs); }

/* ------------------------------------------------------------ narrower */

/* Below this the assistant cannot be a column and stay useful, so it goes
   back to being a drawer - over the plan, with a scrim, closed by default. */
@media (max-width: 1199px) {
    .planner-body { display: block; }
    #assistant-layer {
        position: fixed;
        inset: 0;
        z-index: 100;
        height: auto;
        border-left: 0;
        background: var(--scrim);
        backdrop-filter: blur(2px);
        animation: overlay-in var(--dur-2) var(--ease) both;
    }
    .assistant-panel {
        width: min(420px, 100vw);
        height: 100%;
        margin-left: auto;
        box-shadow: var(--shadow-4);
    }
}

@media (max-width: 1000px) {
    :root { --rail-w: 220px; }
}

@media (max-width: 760px) {
    .planner-topbar { height: 56px; padding: 0 var(--space-3); }
    .planner-topbar .brand-copy { display: none; }
    .topbar-actions .assistant-button { display: none; }
    .trip-head { padding: var(--space-4) var(--space-4) var(--space-3); }
    .trip-head h1 { font-size: var(--text-lg); }
    /* The route is as long as the trip is, and it was running under the button
       beside it. It scrolls sideways on its own line instead. */
    .journey-row { flex-direction: column; align-items: stretch; gap: var(--space-2); }
    .journey-strip {
        overflow-x: auto;
        padding-bottom: var(--space-1);
        scrollbar-width: none;
    }
    .journey-strip::-webkit-scrollbar { display: none; }
    /* Squeezing every chip to a shared fraction of the width is what you do
       when the strip cannot scroll. It can here, so they keep their names. */
    .journey-strip.is-tight .journey-node,
    .journey-strip.is-tight .journey-more-wrap,
    .journey-strip.is-tight .journey-chip { flex: 0 0 auto; max-width: none; }
    .edit-route-button { align-self: flex-start; }
    .planner-grid { display: block; }

    /* The rail is a column of expanded nights on a wide screen and, unchanged,
       an entire phone screen of them before the itinerary starts. On a phone it
       is navigation instead: one row of days, scrolling sideways, pinned under
       the topbar. Editing the stops themselves is behind Edit route, which is
       the better place for it on a small screen anyway. */
    .day-rail {
        position: sticky;
        top: 56px;
        z-index: 20;
        max-height: none;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: var(--space-2) 0;
        background: var(--canvas);
    }
    .rail-heading { display: none; }
    .stop-rail-over { margin: 0 var(--space-4) var(--space-2); }
    .day-list {
        flex-direction: row;
        gap: var(--space-2);
        overflow-x: auto;
        scroll-snap-type: x proximity;
        padding: var(--space-1) var(--space-4);
        scrollbar-width: none;
    }
    .day-list::-webkit-scrollbar { display: none; }
    .day-row {
        flex: 0 0 auto;
        width: 186px;
        scroll-snap-align: start;
    }
    .day-row-stats { display: none; }
    .day-rail-route { flex: 0 0 auto; width: 150px; margin-top: 0; }
    .day-canvas, .trip-workspace { padding: var(--space-4) var(--space-4) 96px; }
    .active-day-heading-row { flex-wrap: wrap; }
    .add-item.add-item-header { margin-left: 0; }
    .day-title-edit { opacity: 1; }
    .timeline-item, .timeline-row, .transport-row { grid-template-columns: 54px 26px minmax(0, 1fr); }
    .timeline-item::before, .timeline-row::before, .transport-row::before { left: 65px; }
    .assistant-panel { width: 100%; }
    .mobile-assistant-fab {
        position: fixed;
        z-index: 45;
        left: var(--space-4);
        right: var(--space-4);
        bottom: var(--space-3);
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: var(--space-2);
        border: 0;
        border-radius: var(--radius-md);
        background: var(--fern);
        color: var(--ink-inverse);
        box-shadow: var(--shadow-3);
        font-size: var(--text-xs);
        font-weight: var(--weight-semi);
    }
}

/* Waiting on the model. The button keeps its arrow and spins its border, so
   the control does not change size or lose its label mid-request. */
.assistant-composer button.is-working {
    position: relative;
    color: transparent;
}
.assistant-composer button.is-working::after {
    content: "";
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--ink-inverse);
    border-radius: 50%;
    animation: assistant-spin 620ms linear infinite;
}
@keyframes assistant-spin { to { transform: rotate(360deg); } }


/* --------------------------------------------------------------- tonight */
/* The one question every day has, answered in the same place every time.
   See the note on tonightCard in main.js. */

.tonight {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    margin-top: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--paper);
}
.tonight.is-empty {
    border-style: dashed;
    border-color: var(--line-strong);
    background: transparent;
}
.tonight-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    background: var(--canvas-2);
    color: var(--ink-2);
}
.tonight.is-empty .tonight-mark { background: transparent; color: var(--ink-3); }
.tonight-copy { display: flex; flex-direction: column; min-width: 0; }
.tonight-label {
    margin: 0 0 2px;
    font-size: var(--text-2xs);
    font-weight: var(--weight-semi);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--ink-3);
}
.tonight-copy strong {
    font-size: var(--text-sm);
    font-weight: var(--weight-semi);
    letter-spacing: var(--tracking-tight);
    overflow: hidden;
    text-overflow: ellipsis;
}
.tonight.is-empty .tonight-copy strong { color: var(--ink-2); font-weight: var(--weight-medium); }
.tonight-copy small { margin-top: 2px; color: var(--ink-3); font-size: var(--text-xs); }
.tonight-action {
    flex: none;
    min-height: 34px;
    padding: 0 var(--space-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: var(--paper);
    color: var(--ink);
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
}
.tonight-action:hover { border-color: var(--fern); color: var(--fern); background: var(--fern-tint); }

/* A long day in the car, marked where the number is. */
.day-stat.is-heavy {
    border-color: var(--caution);
    background: var(--caution-tint);
    color: var(--caution);
}
.day-stat svg, .stat-pill svg { flex: none; }

@media (max-width: 620px) {
    .tonight { grid-template-columns: 40px minmax(0, 1fr); }
    .tonight-action { grid-column: 1 / -1; justify-self: start; }
}

/* Kinds of activity, drawn apart. A day of identical green pins is a list;
   these are the shapes an afternoon actually comes in. */
.kind-food .timeline-card, .timeline-card.kind-food { border-left: 3px solid var(--caution); }
.kind-food .timeline-marker { background: var(--caution-tint); color: var(--caution); }
.kind-label.kind-food, .kind-food .item-kind-label { color: var(--caution); background: var(--caution-tint); }

.kind-rest .timeline-card, .timeline-card.kind-rest { border-left: 3px solid var(--line-strong); }
.kind-rest .timeline-marker { background: var(--canvas-2); color: var(--ink-3); }
.kind-label.kind-rest, .kind-rest .item-kind-label { color: var(--ink-3); background: var(--canvas-2); }

.kind-admin .timeline-card, .timeline-card.kind-admin { border-left: 3px solid var(--ink-3); }
.kind-admin .timeline-marker { background: var(--canvas-2); color: var(--ink-2); }
.kind-label.kind-admin, .kind-admin .item-kind-label { color: var(--ink-2); background: var(--canvas-2); }

/* Every leg that is not a drive or a flight: a sailing, a coach, a train, a
   walk. They are journeys with a ticket, so they are drawn like the flight. */
.kind-ferry .timeline-card, .kind-bus .timeline-card, .kind-train .timeline-card,
.kind-walk .timeline-card {
    border-left: 3px solid var(--calm);
    background: var(--paper);
}
.kind-ferry .timeline-marker, .kind-bus .timeline-marker,
.kind-train .timeline-marker, .kind-walk .timeline-marker {
    background: var(--calm-tint);
    color: var(--calm);
}
.kind-ferry .item-kind-label, .kind-bus .item-kind-label,
.kind-train .item-kind-label, .kind-walk .item-kind-label {
    color: var(--calm);
    background: var(--calm-tint);
}
