/* The phone-size layout: under 1200 px wide or under 600 px tall, on any device (PHONE_LAYOUT in web/, the same test). Last of the
   page's five files, so that its rules win where they meet the others'. */
/* The phone layout: under 1200 px wide or under 600 px tall, on any device (PHONE_LAYOUT, the same test). The values every piece there shares: the bar, the map's box, the
     tools and the credit on it, time, the search, the shape's bar, the guide. The page's interface adds its sheet over these (web/interface.css); a frame, which has no
     interface, stands its comparison window under the map from them. Every height comes from these variables. */
@media (max-width: 1199px), (max-height: 599px) {
  /* the map */
  #gl,
  #selfx,
  #sweep,
  #tourfx {
    position: absolute;
    inset: auto;
    left: 0;
    top: var(--bar-h);
    width: var(--map-w);
    height: var(--map-h);
  }
  #legend,
  #bar,
  .ty,
  #ticks {
    display: none;
  }
  /* On the map the column of tools stands at the right foot, as on a desktop, and the credit at the left, above the imprint: at 12 px the credit is
     200 px or more across, about as wide as the imprint's address, and the two do not fit side by side. The corner's box gives way to its two children. */
  #mapcorner {
    display: contents;
  }
  #stack {
    position: absolute;
    z-index: 4;
    right: calc(100vw - var(--map-w) + 4px);
    bottom: calc(var(--full) - var(--bar-h) - var(--map-h) + 2px);
  }
  #credit {
    position: absolute;
    z-index: 4;
    left: 4px;
    bottom: calc(var(--full) - var(--bar-h) - var(--map-h) + 7px + var(--imprint-h, 31px));
    text-align: left;
  }
  #stack button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }
  /* the compass shows only when the map is turned: out of the column's flow, above it where it was, so that its slot is not kept while it is
     hidden (the credit at 12 px took the room on the smallest map) */
  #stack #north {
    position: absolute;
    bottom: 100%;
    margin-bottom: 4px;
  }
  /* while a shape is drawn the map is the drawing's: the column gives way */
  .drawing #stackpill {
    display: none;
  }
  /* the column on the map: the same tools as on a desktop, less the zoom buttons (two fingers zoom) and live reading (the Map tool's) */
  #stack #zin,
  #stack #zout,
  #stack #live {
    display: none;
  }
  #svhint {
    top: calc(var(--bar-h) + 6px);
    bottom: auto;
    left: 8px;
    right: 56px;
    max-width: none;
  }
  #credit {
    max-width: min(224px, calc(var(--map-w) - 60px));
  }
  /* with the interface hidden (a frame, or H) no column of tools stands beside it: wide enough for its two natural lines, the licence on one
     and GHSL with NASADEM on the other, not three, which on a frame 300 px tall took the room the outlined places' labels need */
  .nohud #credit {
    max-width: min(244px, calc(var(--map-w) - 8px));
  }
  #credit .nb {
    white-space: normal; /* a licence obligation: on the narrowest phone it wraps rather than run off the screen */
  }
  /* on the phone layout's map, at its top, clear of the imprint and the credit at its foot */
  #tourplay {
    left: calc(var(--map-w) / 2);
    top: calc(var(--bar-h) + 12px);
    bottom: auto;
  }
  #imprint {
    --imp: 12px;
    left: 4px;
    bottom: calc(var(--full) - var(--bar-h) - var(--map-h) + 2px);
    padding: 2px 6px;
    border-radius: 4px;
  }
  #imprint .h {
    gap: 4px;
    line-height: 15px;
  }
  #imprint .a {
    font-size: 12px;
    line-height: 14px;
  }
  #imprint svg {
    width: 10px;
    height: 10px;
  }
  #status,
  #nojs {
    top: calc(var(--bar-h) + var(--map-h) / 2);
    left: calc(var(--map-w) / 2);
  }
  .map-up #status {
    top: auto;
    bottom: calc(var(--full) - var(--bar-h) - var(--map-h) + 30px);
  }
  /* the bar: the subject's name, which is also the way to the search; × for one area; the year; near me; the start view; map only; the guide */
  #head {
    z-index: 6;
    left: 0;
    right: 0;
    top: 0;
    max-width: none;
    height: var(--bar-h);
    padding: env(safe-area-inset-top, 0px) calc(2px + var(--safe-r)) 0 calc(4px + var(--safe-l));
    box-sizing: border-box;
    display: flex;
    align-items: center;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    pointer-events: auto;
    text-shadow: none;
  }
  #head h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  #head::before,
  #sub,
  #headline,
  .sb-glass,
  #searchq,
  #searchclose {
    display: none;
  }
  #searchbox,
  .sb-row {
    display: contents;
  }
  #barfind {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
    height: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 8px 0 7px;
    border: 1px solid var(--field-rule);
    border-radius: 9px;
    background: var(--field);
    color: var(--ink);
    text-align: left;
  }
  #barfind .sb-glass {
    display: block;
  }
  #barname {
    flex: 1;
    min-width: 0;
    font-size: 12.5px;
    line-height: 14px;
    font-weight: 600;
    white-space: normal;
    overflow-wrap: anywhere;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
  #barclear[hidden] {
    display: none;
  }
  #barclear {
    order: 2;
    font-size: 20px;
    color: var(--ink);
  }
  #year {
    order: 3;
    flex: none;
    margin: 0 3px 0 5px;
    font-size: 15px;
    letter-spacing: 0;
    gap: 0;
    flex-direction: column;
    align-items: flex-end;
  }
  #imprint .s {
    white-space: normal;
    max-width: 170px;
  }
  #nearme {
    order: 4;
  }
  #barinfo {
    order: 7;
  }
  .barbtn,
  #nearme {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--bar-btn);
    min-width: var(--bar-btn);
    height: 44px;
    min-height: 44px;
    padding: 0;
    gap: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink);
    --bar-btn: clamp(38px, 10.7vw, 44px);
  }
  .barbtn svg,
  #nearme svg {
    width: 18px;
    height: 18px;
    overflow: visible;
  }
  #nearme span {
    display: none;
  }
  #barinfo[aria-pressed='true'] {
    background: var(--ctl-on);
  }
  /* searching: the whole bar is the field, with near me still beside it */
  .searching #barfind,
  .searching #barclear,
  .searching #year,
  .searching #barinfo {
    display: none;
  }
  .searching #head > #searchbox > .sb-row > .sb-glass {
    display: block;
    order: 0;
    margin: 0 2px 0 6px;
  }
  .searching #searchq {
    display: block;
    order: 1;
    flex: 1 1 0;
    height: 40px;
    font-size: 16px; /* under this, a phone's browser zooms the page on focus */
  }
  .searching #nearme {
    order: 2;
  }
  .searching #searchclose {
    display: inline-flex;
    order: 3;
    font-size: 22px;
  }
  #searchlist {
    position: fixed;
    z-index: 7;
    left: 4px;
    right: 4px;
    top: calc(var(--bar-h) + 2px);
    max-height: calc(var(--full) - var(--bar-h) - 10px);
    font-size: 14px;
  }
  #searchlist [role='option'] {
    padding: 9px 8px;
  }
  #searchsay {
    position: fixed;
    z-index: 7;
    left: 4px;
    right: 4px;
    top: calc(var(--bar-h) + 2px);
    margin: 0;
  }
  /* time: Play and the timeline, whose track is the legend */
  #foot {
    top: calc(var(--bar-h) + var(--map-h));
    bottom: auto;
    right: auto;
    width: var(--map-w);
    height: var(--time-h);
    box-sizing: border-box;
    padding: 0 8px 0 calc(2px + var(--safe-l));
    gap: 0;
  }
  #play {
    flex: none;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    border: 0;
  }
  #play svg {
    width: 16px;
    height: 16px;
  }
  .tl {
    height: var(--time-h);
    display: block;
  }
  #time {
    position: absolute;
    left: 0;
    top: 0;
    height: 38px;
  }
  input#time::-webkit-slider-runnable-track {
    background: transparent;
  }
  input#time::-moz-range-track {
    background: transparent;
  }
  input#time::-moz-range-progress {
    background: transparent;
  }
  input#time::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
    margin-top: -10px;
    box-shadow: 0 0 0 1.5px var(--bg);
  }
  #tlfill {
    display: none;
  }
  #tlthumb {
    top: 8px;
    width: 22px;
    height: 22px;
    box-shadow: 0 0 0 1.5px var(--bg);
  }
  input#time::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }
  #band,
  #bandafter,
  #bandyears {
    display: block;
    position: absolute;
    pointer-events: none;
  }
  #band {
    left: 0;
    right: 0;
    top: 14px;
    height: 10px;
    border-radius: 2px;
  }
  #bandafter {
    left: var(--thumb-r);
    right: 0;
    top: 14px;
    height: 10px;
    border-radius: 0 2px 2px 0;
    background: var(--bg);
    opacity: 0.68;
    transform-origin: 100% 50%;
    transform: scaleX(1); /* 1 - the year's share, set by web/map.js (placeTime) */
    will-change: transform;
  }
  #bandyears {
    left: var(--thumb-r);
    right: var(--thumb-r);
    top: 27px;
    height: 13px;
    font-size: 9.5px;
    line-height: 13px;
    color: var(--dim);
  }
  #bandyears span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
  }
  /* the panel: the same panel in the same order, under the map or beside it, in the page's colours; what it holds scrolls */
  #panel {
    position: absolute;
    left: var(--panel-left);
    right: 0;
    top: var(--panel-top);
    bottom: 0;
    width: auto;
    border-left: 0;
    touch-action: manipulation;
  }
  #pnopen {
    padding: 10px calc(12px + var(--safe-r)) calc(12px + var(--safe-b)) 12px;
    gap: 12px;
  }
  #pnfold,
  .pn-head {
    display: none;
  }
  #cchart .chart-box {
    height: 170px;
  }
  /* fingertip-size controls */
  .pn-chip,
  .pn-add {
    height: 44px;
    border-radius: 22px;
  }
  .pn-x,
  .pn-mini {
    min-width: 44px;
    height: 44px;
    border-radius: 22px;
  }
  .pn-link,
  #modedone {
    min-height: 44px;
  }
  .pn-link {
    display: inline-flex;
    align-items: center;
  }
  #modebar {
    top: calc(var(--bar-h) + 8px);
    left: calc(var(--map-w) / 2);
    max-width: calc(var(--map-w) - 16px);
  }
  /* a shape being drawn or changed: its bar in the strip under the map */
  .drawing #modebar {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: var(--map-w);
    max-width: none;
    min-height: var(--shape-h);
    transform: none;
    border-radius: 0;
    padding: 6px 10px var(--safe-b);
  }
  /* in the shape bar's 96 px: what to do on one or two lines, then the tool's buttons and Done on one row; no Esc to press on a phone */
  .drawing #modebar:not(.session) {
    height: var(--shape-h);
    box-sizing: border-box;
    align-content: center;
    gap: 4px 6px;
    overflow: hidden;
  }
  .drawing #modetext {
    flex: 1 1 100%;
    font-size: 13px;
    line-height: 1.3;
  }
  .drawing #modeesc {
    display: none;
  }
  .drawing #measurehost {
    flex: 1 1 auto;
  }
  .drawing #modebar .selection-draw button {
    padding: 0 8px;
    min-height: 44px;
  }
  /* a tool, in the same place, the same height */
  #depth {
    margin-top: 0;
  }
  ol.items li {
    min-height: 44px;
    box-sizing: border-box;
  }
  ol.rank li button,
  ol.facts li button {
    min-height: 44px;
    box-sizing: border-box;
  }
  .flip {
    min-width: 44px;
    min-height: 44px;
  }
  ol.items .cp {
    min-height: 44px;
  }
  .ctl {
    margin: 0;
    gap: 2px;
  }
  .ctl > .seg {
    flex: 1 1 auto;
    padding-left: 1px;
    padding-right: 1px;
  }
  .ctl .seg button {
    min-width: 40px;
    padding: 0;
  }
  /* a chart in a tool takes what its words leave, so a tool never scrolls for a chart */
  #depth.fills {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  #depth.fills > .chart-box {
    flex: 1 1 0;
    min-height: 88px;
  }
  #depth .lead {
    margin: 2px 0;
    font-size: 13px;
    line-height: 18px;
  }
  /* the rings' key stands on the chart, and says the numbers only while a ring is being read */
  #depth.fills > .chart-box {
    position: relative;
  }
  #depth.fills .chart-read {
    position: absolute;
    right: 0;
    top: 0;
    margin: 0;
    padding: 1px 4px;
    border: 0;
    border-radius: 4px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    font-size: 12px;
    line-height: 14px;
    pointer-events: none;
  }
  #depth.fills .chart-read:not(.reading) .cr-head,
  #depth.fills .chart-read:not(.reading) .v {
    display: none;
  }
  /* the table: a header of one row, rows of 32 */
  table.cmp-rows th[scope='row'] small {
    display: none;
  }
  table.cmp-rows th[scope='col'] {
    font-size: 12px;
    line-height: 14px;
    vertical-align: bottom;
    padding-top: 0;
    padding-bottom: 0;
  }
  table.cmp-rows tbody tr {
    height: 31px;
  }
  table.cmp-rows tbody td,
  table.cmp-rows tbody th {
    padding-top: 0;
    padding-bottom: 0;
    vertical-align: middle;
  }
  /* one area: its chart, and its number at the line's end */
  /* a shape being drawn: the bar, the map, time and the shape bar; the map shows more below, and what was on screen stays where it was (setGrown, web/map.js) */
  .drawing {
    --map-h: calc(var(--full) - var(--bar-h) - var(--time-h) - var(--shape-h));
  }
  .drawing #panel {
    display: none;
  }
  .sess-say {
    font-size: 13px;
    color: var(--ink);
    min-height: 18px;
  }
  .sess-row button {
    min-height: 44px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    padding: 0 2px;
    white-space: normal;
    line-height: 1.1;
  }
  ol.items .cp {
    padding: 0 6px;
    font-size: 12px;
  }
  #measurehost {
    flex: 1;
    align-items: stretch;
  }
  /* a frame asked to show the interface (the contract's ui: "full"): the bar, the map down to the time row, the tools; no panel */
  .embed #wrap:not(.nohud) {
    --map-h: calc(var(--full) - var(--bar-h) - var(--time-h) - var(--safe-b));
  }
  .touring {
    --map-h: calc(var(--full) - var(--bar-h));
    --map-w: 100vw;
  }
  .touring #head {
    display: flex;
  }
  .touring #barfind,
  .touring #barclear,
  .touring #year,
  .touring #nearme,
  .touring #barinfo {
    display: none;
  }
  #storystop {
    z-index: 7;
    top: calc(env(safe-area-inset-top, 0px) + 2px);
    right: 6px;
    min-height: 40px;
    box-shadow: none;
  }
  /* the guide: below the map, which stays on screen and still works */
  #datahelp {
    position: fixed;
    inset: auto;
    top: var(--panel-top);
    left: var(--panel-left);
    right: 0;
    bottom: 0;
    z-index: 5;
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: var(--bg);
    overscroll-behavior: contain;
  }
  #datahelp article {
    padding: 0 12px 16px;
  }
  #datahelp header {
    position: sticky;
    top: 0;
    z-index: 1;
    height: var(--tabs-h);
    margin: 0 -12px 8px;
    padding: 0 0 0 4px;
    box-sizing: border-box;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
  }
  #datahelp header form button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    font-size: 22px;
  }
  #datahelp .dlg-tabs {
    height: var(--tabs-h);
    padding: 0;
    margin: 0;
    background: none;
    gap: 0;
    border-radius: 0;
  }
  #datahelp .dlg-tabs button {
    min-height: 43px;
    height: 100%;
    padding: 0 12px;
    background: none;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 600;
  }
  #datahelp .dlg-tabs button[aria-selected='true'] {
    color: var(--ink);
    box-shadow: inset 0 -2.5px 0 var(--ink);
  }
  #datahelp [data-copy-link] {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
  #datahelp header form .w {
    display: none;
  }
  #datahelp header form .x {
    display: inline;
  }
  #areatag {
    max-width: calc(var(--map-w) - 16px);
  }
  /* H, and whatever hides the interface: the map alone, with its credit and imprint */
  .nohud {
    --bar-h: 0px;
    --time-h: 0px;
    --map-w: 100vw;
    --map-h: var(--full);
  }
  /* a page framing the map with the comparison open: the map above at its upright share, the window under it, as the phone layout stands */
  .embed .nohud.embed-compare {
    --map-h: calc(var(--full) * var(--map-share));
    --panel-top: var(--map-h);
    --panel-left: 0px;
  }
  .nohud #head {
    display: none;
  }
  .nohud #imprint,
  .nohud #mapcorner {
    bottom: 2px;
  }
}
/* Side by side: the bar across the top; the map and time at the left; the tabs and the panel at the right */
@media (max-width: 1199px) and (min-aspect-ratio: 1201/1000),
  (max-height: 599px) and (min-aspect-ratio: 1201/1000) {
  #panel,
  #datahelp {
    border-left: 1px solid var(--rule);
  }
  /* the shape bar is a narrow column here, and the map takes the rest of the width */
  .drawing {
    --map-h: calc(var(--full) - var(--bar-h) - var(--time-h) - var(--safe-b));
    --map-w: calc(100vw - 204px);
  }
  .drawing #modebar {
    left: auto;
    right: 0;
    width: 204px;
    top: var(--bar-h);
    bottom: 0;
    box-sizing: border-box;
    align-content: flex-start;
    border-left: 1px solid var(--rule);
  }
  .drawing #modebar .selection-draw {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .drawing #modebar:not(.session) {
    height: auto;
    align-content: flex-start;
  }
  .drawing #measurehost,
  .drawing #modedone {
    flex: 1 1 100%;
  }
  .sess-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .embed #wrap:not(.nohud) {
    --map-w: 100vw;
  }
  .embed #wrap:not(.nohud) #foot {
    width: 100vw;
  }
}
@media (prefers-reduced-motion: reduce) {
  #north svg {
    transition: none;
  }
}
.cmp-rows td {
  font-variant-numeric: tabular-nums;
}
.touring .selection-tip {
  display: none;
}
/* A page framing a comparison in a narrow frame (the essay's phone band, about 390 px wide and 300 to 450 tall): the map above, never beside,
   and under it the sentence and the whole chart, the chart taking what the sentence leaves; the areas' chips, the measure, the rows and the other
   ways to look are the full map's. The map keeps 42% of the frame, but never so much that the panel has under 200 px. */
@media (max-width: 599px) {
  .embed .nohud.embed-compare {
    --map-w: 100vw;
    --map-h: max(96px, min(calc(var(--full) * 0.42), calc(var(--full) - 200px)));
    --panel-top: var(--map-h);
    --panel-left: 0px;
    --panel-now: 0px;
  }
  .embed .nohud.embed-compare #pnareas,
  .embed .nohud.embed-compare #pnmeasure,
  .embed .nohud.embed-compare #pnrows,
  .embed .nohud.embed-compare #pnview,
  .embed .nohud.embed-compare #pnothers,
  .embed .nohud.embed-compare #pnmapmore,
  .embed .nohud.embed-compare #pngroundkey {
    display: none !important;
  }
  .embed .nohud.embed-compare #pnopen {
    overflow: hidden;
    padding: 8px 12px;
  }
  .embed .nohud.embed-compare #pnbody,
  .embed .nohud.embed-compare #pnmain,
  .embed .nohud.embed-compare #pnanswer {
    flex: 1 1 auto;
    min-height: 0;
  }
  .embed .nohud.embed-compare #cchart {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .embed .nohud.embed-compare #cchart .chart-box {
    flex: 1 1 0;
    height: auto;
    min-height: 96px;
  }
}
