:root {
  --color-text: #333333;
  --color-text-gray: #666666;

  --base-line-height: 1.5;
  --base-font-size: .8rem;
  --headline-font-size: 1rem;

  --text-max-width: 90ch;

  --section-spacing: 1rem;

  --histogram-color: #ffc800;

  /* Dewey category colors - 2005 installation palette (flat bands) */
  --dewey-000: rgb(135, 153, 135);
  --dewey-100: rgb(95, 90, 252);
  --dewey-200: rgb(56, 142, 156);
  --dewey-300: rgb(72, 185, 105);
  --dewey-400: rgb(150, 200, 61);
  --dewey-500: rgb(223, 225, 28);
  --dewey-600: rgb(242, 100, 34);
  --dewey-700: rgb(239, 59, 36);
  --dewey-800: rgb(108, 81, 160);
  --dewey-900: rgb(153, 46, 146);
}

* {
  box-sizing: border-box;
}

html:has(> body.installation) {
  overflow: hidden;
  overscroll-behavior: none;
}

/* See the note above .status-bar-edge in tpl.whitney.html */
.status-bar-edge {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 12px;
  background: #fff;
  pointer-events: none;
  z-index: 2147483647;
}

body {
  font-size: 16px;
  line-height: var(--base-line-height);
  font-family: "verdana", "arial", "helvetica", "sans-serif";
  font-weight: normal;
  margin: auto;
  padding: 1rem 3rem;
  color: var(--color-text);
  max-width: 1200px;

  &:not(.installation) {
    .dewey-text {
      color: inherit;
    }
  }
}

section {
  margin-bottom: var(--section-spacing);

  &:last-child {
    margin-bottom: 0;
  }
}

p {
  font-size: var(--base-font-size);
  margin: 0;
  color: var(--color-text-gray);
  max-width: var(--text-max-width);
}

label {
  font-size: var(--base-font-size);
  color: var(--color-text);
}

select,
input[type=submit] {
  height: 2.5rem;
  padding: 0 0.5rem;
  font-size: var(--headline-font-size);
  color: var(--color-text);
  border-radius: 0;
}

input[type=submit] {
  border: none;
  /* background: var(--dewey-100); */
  background: var(--histogram-color);
  color: #000000;

  &:active,
  &:hover {
    opacity: .75;
    cursor: pointer;
  }
}

ul {
  margin: 0;
  padding: 0;
  padding-inline-start: 1rem;
}

li {
  padding: 0;
  margin: 0;
  font-size: var(--base-font-size);
  max-width: var(--text-max-width);
}

table {
  border-spacing: 0;
}

/* modern pages only: the original page (body.original) sizes its tables with
   the original width attributes, which these rules would override */
body:not(.original) table {
  width: 100%;

  td:first-child {
    width: 48px;
  }
}


td {
  font-size: var(--base-font-size);
  color: var(--color-text-gray);
}


h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: var(--headline-font-size);
  text-decoration: none;
  margin: 0;
  padding: 0;
  color: var(--color-text);
  max-width: var(--text-max-width);
}

h1 {
  /* font-size: 1.25rem; */
  margin-bottom: 1rem;
}

a {
  font-size: var(--base-font-size);
  color: var(--color-text);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
  }
}

img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
}

/* Added to <body> of the original page (index.php / web/tpl.html): keeps the
   original 2005 fixed-table layout while sharing the typography and colors
   defined above. */
.original {
  max-width: none;

  h1 {
    /* font-size: var(--headline-font-size); */
    margin-bottom: 0;
  }
}

/* Added to <body> for any installation specific styling */
.installation {
  --base-line-height: 1.4;
  --base-font-size: 1.1rem;
  --headline-font-size: var(--base-font-size);
  --text-max-width: none;
  --section-spacing: 0;

  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
  touch-action: manipulation;
  min-height: 100dvh;
  max-width: 1440px;

  /* kiosk: no scrolling; the touchmove handler in tpl.whitney.html stops the
     rubber-band bounce. Not position: fixed - on iOS 26+ home-screen apps a
     fixed body anchors to the screen top and slides under the status bar. */
  /* iPadOS 27 home-screen apps shift the page down by the status bar height
     but still report a full-screen viewport (safe-area insets read 0), so the
     bottom of a 100dvh body is off-screen. Measured 32px on iPad Pro 11" (M5). */
  --ios-statusbar-offset: 0px;
  height: calc(100dvh - var(--ios-statusbar-offset));
  overflow: hidden;
  overscroll-behavior: none;

  @media (display-mode: standalone) {
    --ios-statusbar-offset: 32px;
  }

  /* kiosk: no text selection, no long-press callout (copy / save image / link
     preview), no drag-lift, no tap flash. Taps on links and form controls
     still work. */
  &,
  & * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
  }

  /* no image is a touch target, so iOS has nothing to offer a long-press
     menu for */
  img {
    pointer-events: none;
  }

  /* the histogram link takes the taps instead, so it needs a real box (the
     base rule is display: contents). width: 100% + flex: auto mirrors the
     global img rule, so linked and bare thumbnails shrink to equal cells. */
  .histogram a {
    display: block;
    width: 100%;
    flex: auto;
    min-width: 0;
    cursor: pointer;
  }

  section {
    /* margin-bottom: .5rem; */

    &:last-child {
      margin-bottom: 0;
    }
  }

  p {
    color: var(--color-text);
  }

  .graph-wrapper {
    /* Doesn't super need it and can eek out a bit more space */
    margin-bottom: 0;
  }

  .histogram {
    min-width: 100%;
  }
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: var(--text-max-width);
}

.input {
  color: var(--color-text);
  width: 360px;
}

.red {
  color: #f00;
}

.gray {
  color: var(--color-text-gray);
}

.small {
  font-size: .75rem;
}

.no-data {
  background: #f4f4f4;
  padding: 1rem;
  margin: 0 0 1rem 0;
}

.graph-wrapper {
  display: grid;
  grid-template-columns: 4fr 3fr;
  gap: 1rem 2rem;
}

@media (max-width: 800px) {
  .graph-wrapper {
    grid-template-columns: 1fr;
  }
}

.amount {
  text-align: right;
  margin-right: .5rem;
}

.footer {
  display: flex;
  gap: 1rem;
}

.histogram-scroll {
  overflow-x: auto;
  margin-inline: -2rem;
  padding-inline: 2rem;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
}

.histogram {
  display: flex;
  width: max-content;

  /* Remove the <a> box from layout so every flex item is an identical <img>
     sized by its HTML width attribute, and all cells flex at the same rate */
  a {
    display: contents;
  }

  img {
    flex: auto;
    min-width: 0;
    height: auto;
  }
}

.date-form {
  display: flex;
  gap: 1rem;
  flex: 5;
}

.date-form-item {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: .25rem;
  width: 100%;

  label {
    font-weight: bold;
    font-size: var(--headline-font-size);
  }
}

.credits {
  align-self: flex-end;
  flex: 3;
}

.dewey-text {
  color: var(--dewey-color);
  font-weight: bold;
}

.dewey-000 {
  --dewey-color: var(--dewey-000);
}

.dewey-100 {
  --dewey-color: var(--dewey-100);
}

.dewey-200 {
  --dewey-color: var(--dewey-200);
}

.dewey-300 {
  --dewey-color: var(--dewey-300);
}

.dewey-400 {
  --dewey-color: var(--dewey-400);
}

.dewey-500 {
  --dewey-color: var(--dewey-500);
}

.dewey-600 {
  --dewey-color: var(--dewey-600);
}

.dewey-700 {
  --dewey-color: var(--dewey-700);
}

.dewey-800 {
  --dewey-color: var(--dewey-800);
}

.dewey-900 {
  --dewey-color: var(--dewey-900);
}
