/* ================================================================================
   RATE A BEER (#rateBeerOverlay)
   Markup: templates/partials/rate-beer.html. Logic: features/rate-beer.js.

   Every rule is scoped to #rateBeerOverlay. Colours are tokens from
   theme.css; nothing here is hard-coded, so there is no dark-mode block.

   Layout: the screen itself does not scroll. Inside it, one part scrolls
   (the beer, how it was had, the glass, notes, then where and photo) and
   the save bar is pinned under it.
   ================================================================================ */

#rateBeerOverlay {
    /* .overlay scrolls by default. This screen scrolls its inner part
       instead, so the save bar stays put. */
    overflow: hidden;
}

#rateBeerOverlay .rate-beer-page {
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
}

/* A column that fills the space above the save bar. Everything in it keeps
   its own height except the glass panel, which takes what is left: that is
   what makes the whole screen fit without scrolling. Scrolling is still
   allowed, for a screen too short even for the smallest glass. */
#rateBeerOverlay .rate-beer-scroll {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: var(--space-md) var(--space-lg);
}

#rateBeerOverlay .rate-beer-scroll > * {
    flex: none;
}

/* ============ THE BEER ============ */
#rateBeerOverlay .rate-beer-name {
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: 800;
    line-height: 1.2;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

#rateBeerOverlay .rate-beer-meta {
    margin-top: var(--space-xxs);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* ============ HOW IT WAS HAD ============ */
#rateBeerOverlay .rate-beer-formats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-sm);
}

/* Small on purpose: four short words, and the height they give up goes to
   the glass. */
#rateBeerOverlay .rate-beer-format {
    min-height: 36px;
    padding: 0 var(--space-xs);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

#rateBeerOverlay .rate-beer-format:active {
    transform: scale(0.96);
}

/* Filled, with dark text: amber text on a pale chip is hard to read in
   light mode. */
#rateBeerOverlay .rate-beer-format.selected {
    background: var(--amber);
    border-color: var(--amber);
    color: var(--text-on-bright);
}

#rateBeerOverlay .rate-beer-format-hint {
    text-align: center;
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
    animation: rate-beer-hint-pop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rate-beer-hint-pop {
    0%   { opacity: 0; transform: translateY(-4px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ============ THE GLASS ============
   A dark panel in light mode as well as dark. The glass is drawn in white
   lines (utils/vessels.js), which vanish on a white card; --primary-gradient
   is dark in both themes, so the same drawing reads in both. Text on the
   panel is --text-white for the same reason.

   The panel is the part of the column that gives: it grows to a comfortable
   size on a tall phone and shrinks on a short one. The glass is as tall as
   the panel allows and takes its width from its shape. */
#rateBeerOverlay .rate-beer-scroll > .rate-beer-meter {
    flex: 1 1 200px;
    min-height: 120px;
    /* The glass's width follows its height, so a taller panel is a wider
       glass. Tied to the screen's width so the score beside it keeps its
       room on a narrow phone. */
    max-height: min(380px, 72vw);
}

#rateBeerOverlay .rate-beer-meter {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-elevated-card);
    background: var(--primary-gradient);
    color: var(--text-white);
}

/* The score in words, beside the glass. */
#rateBeerOverlay .rate-beer-readout {
    flex: 1 1 0;
    min-width: 0;
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xxs);
    text-align: center;
}

#rateBeerOverlay .rate-beer-emoji {
    font-size: var(--text-4xl);
    line-height: 1.1;
}

#rateBeerOverlay .rate-beer-word {
    font-size: var(--text-md);
    font-weight: 700;
    line-height: 1.2;
}

#rateBeerOverlay .rate-beer-number {
    font-size: var(--text-3xl);
    font-weight: 800;
    line-height: 1.1;
    color: var(--amber);
    font-variant-numeric: tabular-nums;
}

/* A small line under the score: what to do while the glass is empty, or
   when they last rated it this way. */
#rateBeerOverlay .rate-beer-meter-note {
    margin-top: var(--space-xs);
    font-size: var(--text-xs);
    line-height: 1.3;
    opacity: 0.7;
}

/* The glass is the control. touch-action: none hands every touch inside it
   to rate-beer.js, so dragging to rate never scrolls the screen. Its height
   is the panel's. Its width is set by rate-beer.js from that height
   (watchGlassSize); the figure here is only what it is before that runs. */
#rateBeerOverlay .rate-beer-glass {
    position: relative;
    flex: none;
    width: var(--rate-beer-glass-width, 120px);
    touch-action: none;
    cursor: ns-resize;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    border-radius: var(--radius);
}

#rateBeerOverlay .rate-beer-glass:focus-within {
    outline: 2px solid var(--amber);
    outline-offset: var(--space-xs);
}

/* Laid over the glass's box, so the drawing never decides the box's size. */
#rateBeerOverlay .rate-beer-vessel {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

#rateBeerOverlay .rate-beer-vessel-svg {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* The same control for keyboards and screen readers. Out of sight and out of
   the way of touches, but still focusable. */
#rateBeerOverlay .rate-beer-slider {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

/* 1 to 5 up the side, each number level with where the beer reaches at
   that score. The drawings fill between fixed heights (vessels.js): the
   bottle's are slightly different from the rest. */
#rateBeerOverlay .rate-beer-scale {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    font-size: var(--text-sm);
    font-weight: 700;
    opacity: 0.7;
}

#rateBeerOverlay .rate-beer-scale span {
    position: absolute;
    left: 0;
    transform: translateY(-50%);
    line-height: 1;
}

#rateBeerOverlay .rate-beer-scale span:nth-child(1) { top: 10.53%; }
#rateBeerOverlay .rate-beer-scale span:nth-child(2) { top: 26.84%; }
#rateBeerOverlay .rate-beer-scale span:nth-child(3) { top: 43.16%; }
#rateBeerOverlay .rate-beer-scale span:nth-child(4) { top: 59.47%; }
#rateBeerOverlay .rate-beer-scale span:nth-child(5) { top: 75.79%; }

#rateBeerOverlay .rate-beer-meter[data-format="bottle"] .rate-beer-scale span:nth-child(1) { top: 5.26%; }
#rateBeerOverlay .rate-beer-meter[data-format="bottle"] .rate-beer-scale span:nth-child(2) { top: 22.76%; }
#rateBeerOverlay .rate-beer-meter[data-format="bottle"] .rate-beer-scale span:nth-child(3) { top: 40.26%; }
#rateBeerOverlay .rate-beer-meter[data-format="bottle"] .rate-beer-scale span:nth-child(4) { top: 57.76%; }
#rateBeerOverlay .rate-beer-meter[data-format="bottle"] .rate-beer-scale span:nth-child(5) { top: 75.26%; }

/* ============ TASTING NOTES ============
   One line tall until there are words in it; rate-beer.js then sets its
   height to fit them, up to the cap here: two lines at rest, more while it
   is being typed in. */
#rateBeerOverlay .rate-beer-comment {
    display: block;
    width: 100%;
    min-height: 44px;
    max-height: 68px;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--text-md);
    line-height: 1.4;
    resize: none;
}

#rateBeerOverlay .rate-beer-comment::placeholder {
    color: var(--text-muted);
}

#rateBeerOverlay .rate-beer-comment:focus {
    max-height: 110px;
    outline: none;
    border-color: var(--border-purple);
    box-shadow: 0 0 0 3px var(--bg-purple);
}

/* ============ WHERE, AND A PHOTO ============ */
/* Two equal columns, whatever the buttons say. */
#rateBeerOverlay .rate-beer-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-sm);
}

#rateBeerOverlay .rate-beer-actions > .rate-beer-action,
#rateBeerOverlay .rate-beer-action-wrap {
    min-width: 0;
}

/* Holds the photo button and its remove cross as siblings. */
#rateBeerOverlay .rate-beer-action-wrap {
    position: relative;
    display: flex;
}

#rateBeerOverlay .rate-beer-action-wrap .rate-beer-action {
    flex: 1;
    min-width: 0;
}

#rateBeerOverlay .rate-beer-action {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-height: 52px;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

#rateBeerOverlay .rate-beer-action:active {
    transform: scale(0.97);
}

#rateBeerOverlay .rate-beer-action-icon {
    flex: none;
    font-size: var(--text-xl);
    line-height: 1;
}

#rateBeerOverlay .rate-beer-action-thumb {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

#rateBeerOverlay .rate-beer-action-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

#rateBeerOverlay .rate-beer-action-label {
    font-size: var(--text-sm);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#rateBeerOverlay .rate-beer-action-hint {
    font-size: var(--text-xs);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Only there once a photo has been picked: the [hidden] rule at the foot of
   this file is what keeps it away until then. */
#rateBeerOverlay .rate-beer-action-remove {
    position: absolute;
    top: calc(-1 * var(--space-sm));
    right: calc(-1 * var(--space-xs));
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-circle);
    border: 1px solid var(--border-medium);
    background: var(--bg-card-elevated);
    color: var(--text-primary);
    font-family: inherit;
    font-size: var(--text-lg);
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

/* The venue as it was recorded, shown but not changeable (the rate prompt,
   a day or more after the beer). */
#rateBeerOverlay .rate-beer-action.locked {
    cursor: default;
    pointer-events: none;
}

/* The phone's own date picker is opened by the When button. The input has
   to be on the page for that to work, so it is laid under the button and
   made invisible instead of being display: none. */
#rateBeerOverlay .rate-beer-when-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

/* ============ SAVE BAR ============
   Pinned under the scrolling part. The + button pokes up over the bottom
   nav by --nav-create-rise (navigation.css); that much extra space under
   the button keeps the two apart. */
#rateBeerOverlay .rate-beer-save-bar {
    flex: none;
    padding: var(--space-md) var(--space-lg) calc(var(--space-sm) + var(--nav-create-rise));
    border-top: 1px solid var(--border-light);
    background: var(--bg-card);
}

#rateBeerOverlay .rate-beer-save {
    display: block;
    width: 100%;
    min-height: 52px;
    padding: var(--space-sm) var(--space-md);
    border: 0;
    border-radius: var(--radius);
    background: var(--amber);
    color: var(--text-on-bright);
    font-family: inherit;
    font-size: var(--text-lg);
    font-weight: 800;
    cursor: pointer;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

#rateBeerOverlay .rate-beer-save:active {
    transform: scale(0.98);
}

#rateBeerOverlay .rate-beer-save:disabled {
    background: var(--bg-muted);
    color: var(--text-muted);
    cursor: not-allowed;
}

#rateBeerOverlay .rate-beer-skip {
    display: block;
    width: 100%;
    min-height: 44px;
    margin-top: var(--space-xs);
    border: 0;
    background: none;
    color: var(--text-link);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 700;
    cursor: pointer;
}

#rateBeerOverlay .rate-beer-skip:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Last, on purpose. A rule that sets `display` beats the hidden attribute,
   and several things above set it (the remove cross, the wraps, the skip
   line). This puts hidden back in charge for the whole screen. */
#rateBeerOverlay [hidden] {
    display: none !important;
}
