/* Prefer border-box */
* {
  box-sizing: border-box;
}

/* Button palette (theme-independent; darkened from #828282 so white text hits AA) */
:root {
  --btn-bg: #6d6d6d;
  --btn-bg-hover: #767676;
  --btn-bg-active: #5c5c5c;
}

/* Keyboard a11y: visible focus ring + skip-to-content link (hidden until focused) */
:focus-visible {
  outline: 2px solid var(--fontcolor, #0a6cff);
  outline-offset: 2px;
}
.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 1000;
  padding: 8px 12px;
  background: var(--bgcolor, #fff);
  color: var(--fontcolor, #000);
  border: 1px solid var(--fontcolor, #000);
  border-radius: 4px;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 8px;
}

/* Links use the tuned --link token (previously fell back to UA blue/purple) */
a {
  color: var(--link);
}
a:visited {
  color: var(--link);
}
a:hover {
  text-decoration: underline;
}

/* General body settings */
html {
  background-color: var(--bgcolor);
  background-image: linear-gradient(var(--bgcolor), var(--bgcolor2));
  /* stop iOS Safari from inflating text inside wide blocks (the table
     caption was getting boosted on real devices only) */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  color: var(--fontcolor);
  background: transparent; /* the wrap layer below shows through */
}
/* Christmas-wrap background: the 1953-1969 logo tiled on an oversized
   fixed layer, rotated 45 degrees left so the grid becomes diagonal
   strips. Sits above the html background, below all content. Knobs:
   background-size = tile density, opacity, rotate() angle. */
body::before {
  content: "";
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  z-index: -1;
  background-image: url("../imgs/logos/Kirby_Logo_1953-1969.svg");
  background-repeat: repeat;
  background-size: 100px auto;
  transform: rotate(-45deg);
  opacity: 0.25;
}
h1 {
  font-size: 1.5em;
  text-shadow: 1px 1px 0 var(--font-shadow);
}
h2 {
  font-size: 1.15em;
  text-shadow: 1px 1px 0 var(--font-shadow);
}

/* center something */
.center {
  max-width: 100%;
  height: auto;
  align-content: center;
  text-align: center;
}

/* Page content column */
.content {
  width: 1200px;
  max-width: 100%;
  margin: 0 auto;
  padding-left: 10px;
  padding-right: 10px;
  padding-top: 8px;
  padding-bottom: 0;
  /* opaque ground so the wrap never sits under text or the table */
  background-color: var(--bgcolor);
  border-radius: 5px;
  box-shadow: 1px 1px 6px 1px var(--footer-text);
}

/* hr styles */
.separator {
  border: none;
  border-top: 1px solid var(--footer-text);
  border-bottom: 1px solid var(--font-shadow);
  width: 100%;
  margin: 1em auto;
}

.note {
  max-width: 50%;
  margin-left: auto;
  margin-right: auto;
}

.gallery img {
  width: 25%;
  height: auto;
  margin: 0.5em 0.5em;
  vertical-align: middle;
  border: 1px solid var(--border);
  transition: box-shadow 0.1s ease;
  border-radius: 2px;
}
.gallery img:hover {
  box-shadow: 0 0 6px 1px var(--imgshadow);
}

/* Buttons (style matches thorium.rocks, darkened for AA text contrast) */
button {
  font-family: inherit;
  padding: 1px 6px;
  box-shadow: 1px 1px 1px 0 var(--buttonborder);
  border: 1px solid var(--border);
  border-radius: 5px;
  background-color: var(--btn-bg);
  color: #ffffff;
  cursor: pointer;
}
button:hover {
  background-color: var(--btn-bg-hover);
}
button:active {
  box-shadow: 1px 1px 1px 0 #222222 inset;
  background-color: var(--btn-bg-active);
}
/* Blog: the "Suck It!" control navigates, so it's an anchor styled to match */
a#vroombutton {
  display: inline-block;
  padding: 1px 6px;
  font-family: inherit;
  box-shadow: 1px 1px 1px 0 var(--buttonborder);
  border: 1px solid var(--border);
  border-radius: 5px;
  background-color: var(--btn-bg);
  text-decoration: none;
}
a#vroombutton:hover {
  background-color: var(--btn-bg-hover);
}
#darkbutton {
  margin: 0.75em auto;
}
#vroombutton {
  margin: 0.75em auto;
  color: #00ffff;
}

/* Wikipedia-style table (matches MediaWiki .wikitable) */
.table-wrap {
  overflow-x: auto;
  /* overflow-x:auto makes overflow-y compute to auto too, which clips the
     table's box-shadow; this padding gives the shadow room inside the clip box */
  padding: 4px;
}
table.wikitable {
  background-color: var(--table-bg);
  color: var(--table-fg);
  border: 1px solid var(--table-border);
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 4px;
  margin: 0 auto;
  font-size: 0.95rem;
  line-height: 1.25;
  width: 90%;
}
table.box {
  box-shadow: 1px 1px 4px 1px var(--footer-text);
}
table.wikitable caption {
  font-weight: bold;
  padding: 8px;
}
table.wikitable th,
table.wikitable td {
  /* Separate borders (not collapse) so the table can round its outer corners.
     Each cell draws only top + left; the first row drops its top and the first
     column drops its left, so the table's own border supplies the outer edges.
     Basing the grid on top/left keeps it rowspan-safe (the service column spans
     rows) and gives a clean 1px grid with no doubling. */
  border-top: 1px solid var(--table-border);
  border-left: 1px solid var(--table-border);
  padding: 6px 10px;
}
table.wikitable thead tr:first-child > * {
  border-top: 0;
}
table.wikitable tr > :first-child {
  border-left: 0;
}
/* round only the four outermost corners (4px) to match the table radius */
table.wikitable thead tr:first-child th:first-child {
  border-top-left-radius: 4px;
}
table.wikitable thead tr:first-child th:last-child {
  border-top-right-radius: 4px;
}
table.wikitable tbody tr:last-child td:first-child {
  border-bottom-left-radius: 4px;
}
table.wikitable tbody tr:last-child td:last-child {
  border-bottom-right-radius: 4px;
}
table.wikitable th {
  background-color: var(--table-th-bg);
  text-align: center;
}
table.wikitable td {
  text-align: center;
}
table.wikitable td.notes {
  text-align: left;
  min-width: 18em;
}
table.wikitable tbody tr:hover {
  background-color: var(--table-hover);
}
table.wikitable .year {
  white-space: nowrap;
}
/* Rowspan-aware service-column hover (class set by js/table-hover.js) */
table.wikitable td.service.svc-hl {
  background-color: var(--table-hover);
}

/* Footnote refs (model serials + patent notes): Wikipedia-style [a] with a hover/tap popup */
.mdl-ref {
  white-space: nowrap;
}
.fn-ref {
  position: relative;
  white-space: nowrap;
}
.fn-ref > button {
  font: inherit;
  color: var(--link);
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0 1px;
  cursor: pointer;
}
.fn-ref > button:hover,
.fn-ref > button:focus-visible {
  text-decoration: underline;
}
.fn-pop {
  display: none;
  position: absolute;
  left: 0;
  top: 1.6em;
  z-index: 30;
  width: max-content;
  max-width: min(22em, 90vw);
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: normal;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  color: var(--table-fg);
  background: var(--table-th-bg);
  border: 1px solid var(--table-border);
  border-radius: 4px;
  box-shadow: 2px 2px 3px var(--imgshadow);
}
.fn-ref:hover .fn-pop,
.fn-ref:focus-within .fn-pop {
  display: block;
}
/* open leftward when the ref sits near the right edge (e.g. patents Notes column) */
.fn-pop.fn-left {
  left: auto;
  right: 0;
}

/* Model thumbnails inside the table */
.model-thumb {
  height: 96px;
  width: auto;
  display: block;
  margin: 0 auto;
  border-radius: 2px;
}

/* Historical Kirby logos under the banner */
div.logo-row {
  padding: 1px;
}
.logo-row img {
  height: 64px;
  width: auto;
  margin: 0.5em 0.5em;
  vertical-align: middle;
}

/* Photo framing: 1px outline (black in light mode, white in dark)
   and a soft glow on hover */
.banner {
  box-shadow: 1px 1px 4px 1px var(--imgshadow);
}
.banner,
.model-thumb {
  border: 1px solid var(--border);
  transition: box-shadow 0.1s ease;
}
.banner:hover {
  box-shadow:
    1px 1px 4px 0 var(--imgshadow),
    0 0 6px 1px var(--imgshadow);
}
.model-thumb:hover {
  box-shadow: 0 0 6px 1px var(--imgshadow);
}

.no-margin {
  margin-top: 0px;
  margin-bottom: 0px;
}
.small-margin {
  margin-top: 8px;
  margin-bottom: 8px;
}

.caption {
  text-align: center;
  font-size: 14px;
  font-weight: normal;
  font-style: italic;
}
.table-caption {
  text-align: center;
  font-size: 12px;
  font-weight: normal !important;
}

/* Top of page */
.header {
  font-size: 16px;
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--footer-text);
  z-index: 10;
}

.navbar {
  /* opaque page-color fill so the tiled logo wallpaper (body::before) doesn't
     show through behind the links and clutter them */
  background-color: var(--bgcolor);
  border-left: 1px solid var(--footer-text);
  border-right: 1px solid var(--footer-text);
  border-bottom: 1px solid var(--footer-text);
  padding: 6px;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 0 4px 1px var(--footer-text);
}

/* Bottom of page */
.footer {
  font-size: 13px;
  padding-bottom: 10px;
  color: var(--footer-text);
  display: flex;
  justify-content: space-between;
}

.totop {
  display: block;
  position: fixed;
  bottom: 0;
  right: 0;
  margin-right: 0.5em;
}

.totop img {
  filter: drop-shadow(3px 2px 1px var(--imgshadow));
  width: 2.5em;
}
.totop img:hover {
  filter: drop-shadow(3px 2px 1px var(--imgshadow))
          drop-shadow(0 0 2px var(--imgshadow));
}
.totop img:active {
  filter: drop-shadow(1px -2px 1px var(--imgshadow));
}

/* The absolute top-right navbar (~290px wide at 16px) would clip the banner
   on mid-width screens; reflow it to a centered static line before that. */
@media (max-width: 1100px) {
  .header {
    position: static;
    text-align: center;
    padding-bottom: 4px;
  }
  .totop img {
    width: 2em;
  }
}

/* Mobile layout */
@media (max-width: 800px) {
  body {
    overflow-x: hidden; /* belt-and-suspenders against stray page widening */
  }
  /* source-code link flows as a normal centered line instead of
     floating over whatever happens to be top-right on a phone */
  .header {
    font-size: 14px;
  }
  .footer {
    font-size: 12px;
  }
  .table-caption {
    font-size: 10px;
    text-align: left;
  }
  .banner {
    height: auto;
    max-height: 200px;
    max-width: 96vw;
  }
  .logo-row img {
    height: 40px;
    margin: 0.25em 0.33em;
  }
  .content {
    padding-left: 8px;
    padding-right: 8px;
    padding-top: 6px;
    padding-bottom: 0;
    /* dynamic-toolbar clearance: mobile browsers park their bottom URL bar
     over the last ~50px of a page (no scroll left to retract it at the
     very bottom), hiding the footer links. Pad past it. */
    margin-bottom: calc(50px + env(safe-area-inset-bottom, 0px));
  }
  /* smaller gift-wrap tiles so a phone-width margin still shows a motif */
  body::before {
    background-size: 64px auto;
  }
  table.wikitable {
    width: 99%;
  }
  .note {
    max-width: 92%;
  }
}
