/*
 * hyd-uturns.css - the U-turn road tally and its arrival question on the home desktop.
 *
 * hyd-uturns.js fills #home-uturns (inside the desktop greeting) with an odometer showing the week and month
 * totals of visitor-submitted U-turns, a "view more" button and an Add yours button. Add yours opens the arrival
 * question (.uturn-arrival): a small form asking for a private name and a count for the day, with minus and plus
 * steppers, a result line and a skip button. "view more" opens the weekly window (.uturn-weeks), a modal dialog
 * holding a table of the city's U-turns week by week with a plain bar per week. Colours come from the --paper-*
 * tokens with inline fallbacks.
 *
 * Loaded after the desktop sheets. Touch sizing follows the pointer (pointer: coarse); the phone breakpoints
 * are 600 px (odometer) and 620 px (question panel; the weekly window becomes a bottom sheet).
 */

/* A small shared road tally belongs with the desktop greeting. */
#home-uturns {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 13px auto 0;
  pointer-events: auto;
  z-index: 44;
  width: max-content;
  max-width: 100%;
  text-shadow: none;
}

/* Odometer strip: road-sign glyph, city label, week and month totals and the open button. */
#world #home #home-uturns .uturn-odometer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 11px;
  border: 1px solid #ffffff40;
  border-radius: 4px;
  background: #171920bc;
  color: #fff;
  box-shadow: 0 1px 5px #0002;
  font: calc(11 * var(--px))/1.15 var(--desktop-font,"Lucida Grande",Tahoma,sans-serif);
}

#world #home #home-uturns .uturn-road-sign {
  font:
    30px/1 Georgia,
    serif;
  color: #edddb8;
}

#world #home #home-uturns .uturn-city-label {
  text-align: left;
  color: #eee;
  font-size: calc(10 * var(--px));
}

#world #home #home-uturns .uturn-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 46px;
  text-align: center;
}

#world #home #home-uturns .uturn-stat strong {
  font:
    700 calc(17 * var(--px))/1 'Lucida Grande',
    Tahoma,
    sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
  color: #fff;
}

#world #home #home-uturns .uturn-stat small {
  font: calc(9 * var(--px))/1.15 var(--desktop-font);
  color: #e3dee8;
}

/* Every button in the widget starts from this small base; the variants below (open, close,
   steppers, submit, skip) override it. */
#world #home #home-uturns button {
  font: calc(11 * var(--px))/1.25 var(--desktop-font);
  min-height: 28px;
  min-width: 0;
  margin: 0;
  border-radius: 3px;
  transform: none;
  letter-spacing: 0;
  text-shadow: none;
}

#world #home #home-uturns .uturn-open {
  padding: 4px 0 4px 12px;
  border: 0;
  border-left: 1px solid #ffffff40;
  background: none;
  box-shadow: none;
  color: #fff;
  white-space: nowrap;
}

/* Arrival question panel. First defined as a fixed floating card; the override near the end of the
   file puts it in the page flow below the counter. */
#world #home #home-uturns .uturn-arrival {
  position: fixed;
  top: clamp(16px, 16dvh, 148px);
  bottom: auto;
  right: auto;
  left: 50%;
  translate: -50% 0;
  width: 350px;
  box-sizing: border-box;
  max-height: calc(100dvh - clamp(16px, 16dvh, 148px) - 16px);
  max-width: calc(100vw - 32px);
  text-align: left;
  color: var(--paper-text,#eee);
  background: var(--paper-panel,#302e34);
  border: 1px solid #7b7b82;
  border-radius: 6px;
  box-shadow: 0 8px 25px #0007;
  overflow: auto;
  font: calc(12 * var(--px))/1.4 var(--desktop-font);
}

#world #home #home-uturns .uturn-arrival[hidden] {
  display: none;
}

/* The question is a modal dialog (hyd-uturns.js): the browser’s own dialog padding goes, and its
   backdrop stays see-through and unblurred (the site’s other dialogs dim and blur the page), so the
   card looks as it did and the desk behind it is only inert. Its heading takes the focus on touch
   screens only so that the keyboard waits for a tap; it is not a control, so it draws no ring. */
#world #home #home-uturns .uturn-arrival {
  padding: 0;
}

#world #home #home-uturns .uturn-arrival::backdrop {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#world #home #home-uturns #uturn-question:focus {
  outline: none;
}

/* Panel title bar and its close button. */
#world #home #home-uturns .uturn-titlebar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 9px;
  color: #25252b;
  background: linear-gradient(#e5e5e5, #b7b7ba);
  border-bottom: 1px solid #777;
  font-size: 11px;
}

#world #home #home-uturns .uturn-close {
  width: 20px;
  min-height: 20px;
  padding: 0;
  border: 1px solid #76767a;
  background: #d7d7d9;
  color: #26262b;
  box-shadow: inset 0 1px #fff;
  font-size: 16px;
}

/* Form: name field, count stepper (minus, number, plus), result line and fine print. */
#world #home #home-uturns .uturn-form {
  padding: 15px;
}

#world #home #home-uturns h2 {
  margin: 0 0 14px;
  color: inherit;
  font: 700 calc(15 * var(--px))/1.35 var(--desktop-font);
  text-transform: none;
  letter-spacing: 0;
}

#world #home #home-uturns .uturn-entry {
  display: flex;
  gap: 5px;
  align-items: center;
}

#world #home #home-uturns .uturn-entry button {
  border: 1px solid #7c7c84;
  background: var(--paper-high,#45434c);
  box-shadow: inset 0 1px #ffffff20;
  color: var(--paper-text,#fff);
  padding: 6px 8px;
  min-height: 33px;
}

#world #home #home-uturns .uturn-entry .uturn-submit {
  margin-left: auto;
  padding-inline: 10px;
  font-size: calc(11 * var(--px));
}

#world #home #home-uturns input {
  box-sizing: border-box;
  width: 46px;
  min-width: 0;
  /* rem: the field grows with the bigger text it holds (33px at the default size). */
  height: calc(33 * var(--px));
  padding: 4px;
  border: 1px solid #8c8794;
  border-radius: 2px;
  background: var(--paper-inset,#201e24);
  color: var(--paper-text,#fff);
  font: calc(16 * var(--px))/1 var(--desktop-font);
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

#world #home #home-uturns .uturn-name-label {
  display: block;
  margin-bottom: 5px;
  font-size: calc(11 * var(--px));
}

#world #home #home-uturns .uturn-name-label span {
  color: var(--paper-muted,#ccc);
}

#world #home #home-uturns #uturn-visitor-name {
  display: block;
  width: 100%;
  margin: 0 0 13px;
  padding: 6px 8px;
  text-align: left;
  font-size: calc(13 * var(--px));
}

/* Hide the native number spinners; the minus and plus buttons replace them. */
#home-uturns input::-webkit-inner-spin-button,
#home-uturns input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#world #home #home-uturns button:disabled {
  opacity: 0.6;
  cursor: default;
}

#world #home #home-uturns .uturn-smallprint {
  font: calc(10 * var(--px))/1.6 var(--desktop-font);
  color: var(--paper-muted,#ccc);
  margin: 12px 0 9px;
}

#world #home #home-uturns .uturn-result {
  font: calc(11 * var(--px))/1.45 var(--desktop-font);
  margin: 10px 0 0;
  color: var(--paper-text,#fff);
}

#world #home #home-uturns .uturn-result:empty {
  display: none;
}

#world #home #home-uturns .uturn-form-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#world #home #home-uturns .uturn-skip {
  padding: 3px 0;
  border: 0;
  background: none;
  color: var(--paper-muted,#ddd);
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

#world #home #home-uturns .uturn-all-total {
  font-size: calc(10 * var(--px));
  color: var(--paper-muted,#ccc);
}

/* Service status line, placed just below the widget (absolute, top 100 percent). */
#world #home #home-uturns .uturn-service-status {
  position: absolute;
  top: 100%;
  padding: 3px 6px;
  color: var(--wallpaper-title-ink,#fff);
  text-shadow: 0 1px 3px #000;
  font: calc(9 * var(--px))/1.4 var(--desktop-font);
}

/* Keyboard focus ring for the widget controls. */
#world #home #home-uturns :is(button, input):focus-visible {
  outline: 2px solid #91c9ff;
  outline-offset: 2px;
}

/* Small phones: a more compact odometer. */
@media (max-width: 600px) {
  #world #home #home-uturns .uturn-odometer {
    gap: 8px;
    padding: 5px 8px;
  }

  #world #home #home-uturns .uturn-city-label {
    font-size: calc(9 * var(--px));
  }

  #world #home #home-uturns .uturn-road-sign {
    font-size: 24px;
  }

  #world #home #home-uturns .uturn-stat strong {
    font-size: calc(15 * var(--px));
  }

  #world #home #home-uturns .uturn-open {
    padding-left: 8px;
    font-size: calc(10 * var(--px));
  }

  #home-uturns {
    margin-top: 12px;
  }
}

/* The arrival question must sit above movable windows, not behind them. */
/* !important: on phones the pocket desktop rule in hyd-mobile-desktop.css (loaded later and more
   specific) gives this block z-index 20, which would otherwise win (measured in Chrome at
   390 px, 6 Oct 2026). hyd-mobile-desktop.css also pins the block with !important in other
   states: 3 while the question is closed, and 99 at 900 px and under while a window stays in
   front of the question (that rule is more specific and beats this one). */
#world #home .portal-brand:has(.uturn-arrival:not([hidden])) {
  z-index: 150 !important;
}

/* Phone: a narrower question panel and a 28 px close button. */
@media (max-width: 620px) {
  #world #home #home-uturns .uturn-arrival {
    max-width: calc(100vw - 24px);
  }

  #world #home #home-uturns .uturn-close {
    width: 28px;
    min-height: 28px;
  }
}

/* P3-15: the question occupies space below its counter; it never floats over controls. */
#world #home #home-uturns .uturn-arrival {
  position: relative;
  inset: auto;
  translate: none;
  margin-top: 10px;
  max-height: none;
  overflow: visible;
  width: 350px;
  max-width: calc(100vw - 28px);
}

/* Touch: the steppers become full 44px targets; "maybe later" keeps its look with an invisible 44px-tall press area. */
@media (pointer: coarse) {
  #world #home #home-uturns .uturn-entry button[data-step] {
    min-width: 44px;
    min-height: 44px;
  }

  #world #home #home-uturns .uturn-skip {
    position: relative;
  }

  #world #home #home-uturns .uturn-skip::after {
    content: '';
    position: absolute;
    inset: -9px 0;
  }
}

/* --- The weekly window: "view more" and its dialog (.uturn-weeks) --- */

/* "view more" sits in the odometer after the totals: a button that looks like a small link. It adds
   no height, so the question sheet below the odometer keeps its place. */
#world #home #home-uturns .uturn-more {
  padding: 4px 2px;
  border: 0;
  background: none;
  box-shadow: none;
  color: #e3dee8;
  font: calc(10 * var(--px))/1.15 var(--desktop-font);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  cursor: pointer;
}

#world #home #home-uturns .uturn-more:hover {
  color: #fff;
}

/* Narrow phones: when the totals and both buttons no longer fit on one line (large totals under
   about 375 px), the buttons wrap below the totals instead of running off the screen. Where the
   line fits, nothing moves. */
@media (max-width: 600px) {
  #world #home #home-uturns .uturn-odometer {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* A small modal window in the question panel's chrome, centred on the screen. */
#world #home #home-uturns .uturn-weeks {
  position: fixed;
  inset: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: fit-content;
  max-height: min(560px, calc(100dvh - 32px));
  box-sizing: border-box;
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #7b7b82;
  border-radius: 6px;
  background: var(--paper-panel,#302e34);
  color: var(--paper-text,#eee);
  box-shadow: 0 8px 25px #0007;
  font: calc(12 * var(--px))/1.4 var(--desktop-font);
  text-align: left;
  text-shadow: none;
  letter-spacing: 0;
  white-space: normal;
}

#world #home #home-uturns .uturn-weeks[open] {
  display: flex;
  flex-direction: column;
}

#world #home #home-uturns .uturn-weeks-titlebar {
  display: flex;
  flex: none;
  justify-content: space-between;
  align-items: center;
  padding: 5px 9px;
  color: #25252b;
  background: linear-gradient(#e5e5e5, #b7b7ba);
  border-bottom: 1px solid #777;
  font-size: 11px;
}

#world #home #home-uturns .uturn-weeks-close {
  width: 20px;
  min-height: 20px;
  padding: 0;
  border: 1px solid #76767a;
  background: #d7d7d9;
  color: #26262b;
  box-shadow: inset 0 1px #fff;
  font-size: 16px;
}

/* The table scrolls inside the window; its column heads stay in view. */
#world #home #home-uturns .uturn-weeks-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 12px 12px;
}

#world #home #home-uturns .uturn-weeks-body:focus-visible {
  outline: 2px solid #91c9ff;
  outline-offset: -2px;
}

#world #home #home-uturns .uturn-weeks-status {
  margin: 12px 0 0;
  font: calc(12 * var(--px))/1.45 var(--desktop-font);
  color: var(--paper-text,#fff);
}

#world #home #home-uturns .uturn-weeks-status:empty,
#world #home #home-uturns .uturn-weeks-table[hidden] {
  display: none;
}

#world #home #home-uturns .uturn-weeks-table {
  width: 100%;
  border-collapse: collapse;
  font: calc(12 * var(--px))/1.3 var(--desktop-font);
  font-variant-numeric: tabular-nums;
}

#world #home #home-uturns .uturn-weeks-table caption {
  padding: 10px 0 6px;
  text-align: left;
  color: inherit;
  font: 700 calc(13 * var(--px))/1.35 var(--desktop-font);
}

#world #home #home-uturns .uturn-weeks-table :is(th, td) {
  padding: 5px 0;
  border-bottom: 1px solid #ffffff1f;
  text-align: left;
  vertical-align: middle;
  font-weight: 400;
}

#world #home #home-uturns .uturn-weeks-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-top: 6px;
  border-bottom-color: #ffffff40;
  background: var(--paper-panel,#302e34);
  color: var(--paper-muted,#ccc);
  font-size: calc(10 * var(--px));
}

/* The week column takes only the width of its dates; the count column takes the rest. */
#world #home #home-uturns .uturn-weeks-table th[scope='row'] {
  width: 1%;
  padding-right: 14px;
  white-space: nowrap;
}

#world #home #home-uturns .uturn-weeks-table .uturn-week-live th {
  font-weight: 700;
}

#world #home #home-uturns .uturn-week-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

#world #home #home-uturns .uturn-week-count {
  flex: none;
  min-width: 6ch;
  text-align: right;
}

#world #home #home-uturns .uturn-week-track {
  flex: 1 1 auto;
  min-width: 0;
}

/* A plain bar: one flat colour, its width the week's share of the largest week. */
#world #home #home-uturns .uturn-week-bar {
  display: block;
  height: 8px;
  max-width: 100%;
  background: #edddb8;
}

/* Phones and narrow windows: the window is a sheet along the bottom edge, with larger text. */
@media (max-width: 620px) {
  #world #home #home-uturns .uturn-weeks {
    inset: auto 0 0;
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - max(12px, env(safe-area-inset-top)));
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
  }

  #world #home #home-uturns .uturn-weeks-body {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  #world #home #home-uturns .uturn-weeks-table {
    font-size: calc(14 * var(--px));
  }

  #world #home #home-uturns .uturn-weeks-table caption {
    font-size: calc(15 * var(--px));
  }

  #world #home #home-uturns .uturn-weeks-table thead th {
    font-size: calc(12 * var(--px));
  }

  #world #home #home-uturns .uturn-weeks-table :is(th, td) {
    padding-block: 8px;
  }
}

/* Touch and narrow windows: the close button is a 44 px target around its 22 px disc. */
@media (max-width: 620px), (pointer: coarse) {
  #world #home #home-uturns .uturn-weeks-titlebar {
    padding-block: 0;
  }

  /* height, not just min-height: the minimum-hit-area rule in hyd-classic-desktop.css pins
     min-height to 24px with !important. */
  #world #home #home-uturns .uturn-weeks-close {
    position: relative;
    width: 44px;
    height: 44px;
    margin-right: -9px;
    border: 0;
    background: none;
    box-shadow: none;
    font-size: 0;
  }

  #world #home #home-uturns .uturn-weeks-close::after {
    content: '×';
    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    width: 22px;
    height: 22px;
    box-sizing: border-box;
    border: 1px solid #76767a;
    border-radius: 3px;
    background: #d7d7d9;
    box-shadow: inset 0 1px #fff;
    color: #26262b;
    font: 16px/20px var(--desktop-font);
    text-align: center;
    pointer-events: none;
  }
}

/* Touch: "view more" is a real 44 px-tall button (it is 28 px tall otherwise): 8 px more above and
   below, taken back by a negative margin of the same size, so the odometer keeps its height and
   nothing beside it moves.
   The 4 Oct layout sweep counts the element's own box, so a pseudo-element hit area would not count.
   It is 51 px wide already. */
@media (any-pointer: coarse) {
  #world #home #home-uturns .uturn-more {
    box-sizing: border-box;
    min-width: 44px;
    min-height: 44px;
    margin-block: -8px;
  }
}

/* --- The months view (R2-3): the window opens on one row per month; a month leads to its weeks --- */

/* The title bar: an optional "‹ months" link on the left, the title, the close button. */
#world #home #home-uturns .uturn-weeks-titlebar > span {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

#world #home #home-uturns .uturn-weeks-back {
  flex: none;
  margin: 0 8px 0 -3px;
  padding: 2px 4px;
  border: 0;
  background: none;
  box-shadow: none;
  color: #1f3f78;
  font: 11px/1.2 var(--desktop-font);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  cursor: pointer;
}

#world #home #home-uturns .uturn-weeks-back:hover {
  color: #000;
}

#world #home #home-uturns .uturn-weeks-back[hidden],
#world #home #home-uturns .uturn-months[hidden] {
  display: none;
}

#world #home #home-uturns .uturn-months h3 {
  margin: 0;
  padding: 10px 0 6px;
  text-align: center;
  font: 700 calc(13 * var(--px))/1.35 var(--desktop-font);
}

#world #home #home-uturns .uturn-months-list {
  display: block;
  margin: 0;
  padding: 0;
  list-style: none;
}

#world #home #home-uturns .uturn-months-list li {
  margin: 0;
  padding: 0;
  border-bottom: 1px solid #ffffff1f;
}

/* A real button that reads as a link: the month, its total and a bar, all centred, the bar
   using the row's width. */
#world #home #home-uturns .uturn-month-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 8px 0 9px;
  border: 0;
  background: none;
  box-shadow: none;
  color: inherit;
  font: calc(12 * var(--px))/1.3 var(--desktop-font);
  font-variant-numeric: tabular-nums;
  text-align: center;
  cursor: pointer;
}

#world #home #home-uturns .uturn-month-name {
  color: #b8d8ff;
  font-size: calc(14 * var(--px));
  text-decoration: underline;
  text-underline-offset: 3px;
}

#world #home #home-uturns .uturn-month-link:hover .uturn-month-name {
  color: #fff;
}

#world #home #home-uturns .uturn-month-live .uturn-month-name,
#world #home #home-uturns .uturn-month-live .uturn-month-count {
  font-weight: 700;
}

#world #home #home-uturns .uturn-month-link:focus-visible {
  outline: 2px solid #91c9ff;
  outline-offset: -2px;
}

#world #home #home-uturns .uturn-month-track {
  display: block;
  width: 100%;
}

#world #home #home-uturns .uturn-month-bar {
  display: block;
  height: 8px;
  max-width: 100%;
  margin-inline: auto;
  background: #edddb8;
}

@media (max-width: 620px) {
  #world #home #home-uturns .uturn-months h3 {
    font-size: calc(15 * var(--px));
  }

  #world #home #home-uturns .uturn-month-link {
    font-size: calc(14 * var(--px));
  }

  #world #home #home-uturns .uturn-month-name {
    font-size: calc(16 * var(--px));
  }
}

/* Touch and narrow windows: the back link is a 44 px-tall target. */
@media (max-width: 620px), (pointer: coarse) {
  #world #home #home-uturns .uturn-weeks-back {
    min-height: 44px;
    height: 44px;
    padding-inline: 6px;
    font-size: 13px;
  }
}
