/*
  HakkinFF1 site styles.
  Fonts, sizes, and colors follow ffhacksterex.digitaldreamers.org (ffhacksterex.css): Ferrum ("ff1") for the menu and
  headings, the system UI stack for body text at 100%, and the darkred/white scheme with #fcc hover and #fcf0f0 table rows.
  The wordmark uses the app's own colors (Hakkin in black, FF1 in red).
*/

@font-face {
  font-family: 'ff1';
  src: url('../fonts/Ferrum.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ffred: darkred;
  --textcolor: white;
  --digest-evenrow: #fcf0f0;
  --menuseltext: deeppink;
  --menuhilite: #fcc;

  --wm-main: black;
  --wm-accent: red;

  --body-text: black;
  --body-bg: white;
  --muted: #555;
  --rule: silver;
  --panel-bg: #f5f5f5;
  --panel-border: #ddd;
  --code-bg: #f6f6f6;

  --asmcolor: blue;
  --asmfade: rgba(0, 0, 255, 0.08);
  --notecolor: green;
  --notefade: rgba(0, 128, 0, 0.08);
  --calloutwidth: 3px;

  --header-height: 4rem;
  --std-fontsize: 100%;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--header-height) + 0.75rem); }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
  font-size: var(--std-fontsize);
  line-height: 1.5;
  margin: 0;
  color: var(--body-text);
  background: var(--body-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding: 0 10% 1rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  background: white;
  color: var(--ffred);
  padding: 0.5rem 1rem;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* ---------------------------------------------------------------------------------------------------------------------
   Header / menu
*/

header.nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: stretch;
  min-height: var(--header-height);
  background-color: var(--ffred);
  color: var(--textcolor);
  font-family: ff1, sans-serif;
  font-size: 1.5em;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

header.nav a.home {
  display: flex;
  align-items: center;
  padding: 0 20px;
  margin: 6px 6px 6px 8px;
  background-color: white;
  border: 2px solid var(--ffred);
  outline: 2px solid white;
  text-decoration: none;
  white-space: nowrap;
}
header.nav a.home:hover { font-weight: normal; }
header.nav a.home:hover .wm-accent { text-shadow: 0 0 4px rgba(255, 0, 0, 0.5); }

.wm-main { color: var(--wm-main); }
.wm-accent { color: var(--wm-accent); }

header.nav .menu {
  display: flex;
  flex: 1;
  align-items: stretch;
}

header.nav .item,
header.nav .dropdown-submenu a {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  color: var(--textcolor);
  background-color: var(--ffred);
  border: 2px solid var(--ffred);
  text-decoration: none;
  white-space: nowrap;
  font: inherit;
  cursor: pointer;
}
header.nav .item.right { margin-left: auto; }

header.nav .item:hover,
header.nav .item:focus-visible,
header.nav .dropdown-submenu a:hover,
header.nav .dropdown-submenu a:focus-visible,
header.nav .dropdown.open > .item {
  background-color: var(--menuhilite);
  color: var(--textcolor);
  text-shadow: 0 0 3px black, 0 0 5px var(--ffred);
  font-weight: normal;
}

header.nav .item.current,
header.nav [aria-current="page"] {
  box-shadow: inset 0 -4px 0 white;
}

header.nav .item:focus-visible,
header.nav .dropdown-submenu a:focus-visible,
header.nav a.home:focus-visible {
  outline: 3px solid white;
  outline-offset: -5px;
}

header.nav .dropdown { position: relative; display: flex; }

header.nav .dropdown > .item::after {
  content: '';
  margin-left: 0.5em;
  border: 0.25em solid transparent;
  border-top-color: currentColor;
  transform: translateY(0.15em);
}

header.nav .dropdown-submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 100%;
  z-index: 1001;
  background-color: var(--ffred);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
header.nav .dropdown:hover .dropdown-submenu,
header.nav .dropdown:focus-within .dropdown-submenu,
header.nav .dropdown.open .dropdown-submenu { display: block; }

header.nav .dropdown-submenu a { display: block; }

header.nav .menu-separator {
  margin: 4px 16px;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.6);
}

header.nav .hamburger {
  display: none;
  margin-left: auto;
  padding: 0 20px;
  font: inherit;
  font-size: 1.25em;
  color: var(--textcolor);
  background: none;
  border: 0;
  cursor: pointer;
}

/* Narrow screens: the menu drops below the header as a vertical list with submenus expanded inline. */
@media (max-width: 900px) {
  header.nav { flex-wrap: wrap; font-size: 1.25em; }
  header.nav .hamburger { display: block; }
  header.nav .menu {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.5);
  }
  header.nav.menu-open .menu { display: flex; }
  header.nav .item.right { margin-left: 0; }
  header.nav .dropdown { flex-direction: column; }
  header.nav .dropdown > .item { cursor: default; }
  header.nav .dropdown > .item::after { display: none; }
  header.nav .dropdown-submenu {
    display: block;
    position: static;
    box-shadow: none;
  }
  header.nav .item,
  header.nav .dropdown-submenu a { padding-top: 10px; padding-bottom: 10px; }
  header.nav .dropdown-submenu a { padding-left: 44px; }
  header.nav .item.current,
  header.nav [aria-current="page"] { box-shadow: inset 6px 0 0 white; }
}

/* ---------------------------------------------------------------------------------------------------------------------
   Footer
*/

footer.site-footer {
  margin-top: 32px;
  background-color: var(--ffred);
  color: var(--textcolor);
  text-align: center;
}
footer.site-footer a { color: var(--textcolor); }
footer.site-footer .backtotop {
  display: block;
  padding-top: 8px;
  font-family: ff1, sans-serif;
  font-size: 1.5em;
  text-decoration: none;
}
footer.site-footer .footer-content {
  padding: 32px 10% 48px;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
}
footer.site-footer .footer-wordmark {
  font-family: ff1, sans-serif;
  font-size: 2em;
  background: white;
  padding: 0 0.5em;
  border: 2px solid white;
}
footer.site-footer .footer-version { font-size: x-large; }

/* ---------------------------------------------------------------------------------------------------------------------
   Headings and text
*/

h1.banner {
  font-family: ff1, sans-serif;
  font-weight: normal;
  font-size: 3.25em;
  line-height: 1.15;
  margin: 1.5rem 0 0.25rem;
}
hr.banner { margin-bottom: 1.5rem; }

h2.highlight, .page-content h2 {
  font-family: ff1, sans-serif;
  font-weight: normal;
  font-size: 2.5em;
  line-height: 1.2;
  margin: 2rem 0 0.75rem;
}

.page-content h3 {
  font-family: ff1, sans-serif;
  font-weight: normal;
  font-size: 1.6em;
  line-height: 1.25;
  margin: 1.75rem 0 0.5rem;
}

.page-content h4 {
  font-size: 1.1em;
  margin: 1.25rem 0 0.25rem;
}

hr {
  border-top: none;
  border-bottom: solid 1px var(--rule);
  margin: 2rem 0;
}

a { color: var(--ffred); }
a:hover { font-weight: bold; }
a:active { color: var(--menuseltext); }
a.site-index { text-decoration: none; }
a.site-index:hover, a.site-index:active { color: var(--menuseltext); }

.lead { font-size: 1.2em; }
.muted { color: var(--muted); }
.bold { font-weight: bold; }
.ff1 { font-family: ff1, sans-serif; }
.pre-wrap { white-space: pre-wrap; }
.overflow-wrap { overflow-wrap: anywhere; }

code, kbd, pre, .code { font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace; font-size: 0.95em; }
code { background: var(--code-bg); padding: 0 0.25em; border-radius: 3px; overflow-wrap: anywhere; }
kbd {
  border: 1px solid #aaa;
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 0.3em;
  background: #fafafa;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--panel-border);
  padding: 0.75rem 1rem;
  overflow-x: auto;
}

.page-content li { margin: 0.2rem 0; }

ol.steps { padding-left: 1.5rem; }
ol.steps > li { margin: 0.6rem 0; padding-left: 0.25rem; }

/* Callouts, after the reference's span.asmnote / span.experimental */
.note, .asmnote, .tip {
  border-left: solid var(--calloutwidth) var(--ffred);
  background: var(--digest-evenrow);
  padding: 0.6rem 1rem;
  margin: 1rem 0;
}
.asmnote { border-color: var(--asmcolor); background: var(--asmfade); }
.tip { border-color: var(--notecolor); background: var(--notefade); }
.note > :first-child, .asmnote > :first-child, .tip > :first-child { margin-top: 0; }
.note > :last-child, .asmnote > :last-child, .tip > :last-child { margin-bottom: 0; }
.callout-label { font-weight: bold; }

/* ---------------------------------------------------------------------------------------------------------------------
   Tables (the reference's table.digest)
*/

div.digest { overflow-x: auto; }

table.digest {
  border-collapse: collapse;
  width: 100%;
  border: 2px solid var(--ffred);
  margin: 1.5em 0;
}
table.digest tr:nth-child(even) { background-color: var(--digest-evenrow); }
table.digest th {
  background-color: var(--ffred);
  color: var(--textcolor);
  border: 1px solid white;
}
table.digest th, table.digest td {
  text-align: left;
  vertical-align: top;
  padding: 8px;
  border: 1px solid var(--ffred);
}
table.digest td:first-child { white-space: nowrap; }
table.digest.wrap td:first-child { white-space: normal; }

table.kv { width: auto; min-width: min(100%, 40rem); }
table.kv th { width: 10rem; white-space: nowrap; }

/* ---------------------------------------------------------------------------------------------------------------------
   Icons, figures, cards
*/

img.icon {
  width: 1.5em;
  height: 1.5em;
  vertical-align: -0.35em;
  margin-right: 0.35em;
}
img.icon.lg { width: 3rem; height: 3rem; vertical-align: middle; }

h2 img.icon, h3 img.icon { width: 1em; height: 1em; vertical-align: -0.1em; }

figure.shot {
  margin: 1.25rem 0 1.75rem;
  max-width: 1366px;
}
figure.shot img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid black;
  padding: 2px;
  background: white;
}
figure.shot figcaption {
  margin-top: 0.4rem;
  font-size: 0.95em;
  color: var(--muted);
  font-style: italic;
}

.shot-placeholder {
  aspect-ratio: 1366 / 768;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 2px dashed var(--ffred);
  background: repeating-linear-gradient(45deg, #fff, #fff 12px, var(--digest-evenrow) 12px, var(--digest-evenrow) 24px);
  color: var(--ffred);
  text-align: center;
  padding: 1rem;
}
.shot-placeholder .ff1 { font-size: 1.75em; }

ul.card-grid {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}
ul.card-grid li { margin: 0; }
a.card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  column-gap: 0.75rem;
  height: 100%;
  padding: 0.85rem 1rem;
  border: 2px solid var(--ffred);
  color: inherit;
  text-decoration: none;
}
a.card:hover, a.card:focus-visible { background: var(--digest-evenrow); font-weight: normal; }
a.card img.icon { grid-row: span 2; width: 3rem; height: 3rem; margin: 0; }
a.card .card-title { font-family: ff1, sans-serif; font-size: 1.4em; color: var(--ffred); line-height: 1.2; }
a.card .card-text { font-size: 0.95em; color: var(--muted); }

.icon-list { list-style: none; padding: 0; }
.icon-list > li { display: flex; gap: 0.75rem; align-items: flex-start; margin: 0.75rem 0; }
.icon-list > li > img.icon { width: 2rem; height: 2rem; flex: none; margin: 0.1rem 0 0; }

nav.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0 0.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: ff1, sans-serif;
  font-size: 1.2em;
}
nav.pager .next { text-align: right; }
nav.pager.top { margin-top: 1rem; }

.breadcrumb { margin: 1rem 0 0; color: var(--muted); }

/* Page-local table of contents */
nav.toc {
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  padding: 0.5rem 1.25rem;
  margin: 1rem 0 1.5rem;
  display: inline-block;
  min-width: min(100%, 22rem);
}
nav.toc .toc-title { font-family: ff1, sans-serif; font-size: 1.3em; }
nav.toc ul { margin: 0.25rem 0 0.5rem; padding-left: 1.25rem; }

/* File trees */
pre.tree { line-height: 1.45; }
pre.tree .desc { color: var(--muted); }

/* ---------------------------------------------------------------------------------------------------------------------
   Home
*/

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin: 2.5rem 0 1rem;
}
.hero img.app-icon { width: 96px; height: 96px; }
.hero .hero-wordmark {
  font-family: ff1, sans-serif;
  font-size: 4.5em;
  line-height: 1;
  margin: 0;
  font-weight: normal;
}
.hero p { margin: 0.25rem 0 0; }

.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0; }

a.dl-button, a.cta {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  font-family: ff1, sans-serif;
  font-size: 1.3em;
  text-decoration: none;
  color: white;
  background: var(--ffred);
  border: 2px solid var(--ffred);
}
a.cta.secondary { color: var(--ffred); background: white; }
a.dl-button:hover, a.cta:hover, a.dl-button:focus-visible, a.cta:focus-visible {
  background: var(--menuhilite);
  color: white;
  text-shadow: 0 0 3px black, 0 0 5px var(--ffred);
  font-weight: normal;
}

/* ---------------------------------------------------------------------------------------------------------------------
   Downloads
*/

article.download { margin: 1rem 0 2rem; }
.version-tag {
  font-size: 0.55em;
  vertical-align: middle;
  color: white;
  background: var(--ffred);
  padding: 0.05em 0.45em;
}
td.sha-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
code.sha { word-break: break-all; }

button.copy-btn {
  font: inherit;
  font-size: 0.9em;
  padding: 0.2rem 0.75rem;
  color: var(--ffred);
  background: white;
  border: 2px solid var(--ffred);
  cursor: pointer;
}
button.copy-btn:hover, button.copy-btn:focus-visible { background: var(--digest-evenrow); }
button.copy-btn.copied { color: white; background: green; border-color: green; }
button.copy-btn.failed { color: white; background: var(--ffred); }

/* ---------------------------------------------------------------------------------------------------------------------
   License documents, acknowledgements, site index
*/

details.doc { margin: 0.5rem 0 1.25rem; }
details.doc > summary {
  cursor: pointer;
  color: var(--ffred);
  font-weight: bold;
  padding: 0.25rem 0;
}
pre.doc-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 32rem;
  overflow-y: auto;
  font-size: 0.85em;
}

ul.ack-list { padding-left: 1.25rem; }
ul.ack-list > li { margin: 0.5rem 0; }

.index-groups {
  columns: 2 26rem;
  column-gap: 3rem;
}
.index-group { break-inside: avoid; margin-bottom: 1.5rem; }
.page-content h2.index-page { font-size: 1.75em; margin: 0.5rem 0 0.25rem; }
.index-group ul { margin: 0.25rem 0; padding-left: 1.25rem; }

/* ---------------------------------------------------------------------------------------------------------------------
   Small screens
*/

@media (max-width: 700px) {
  .page-content { padding: 0 16px 1rem; }
  footer.site-footer .footer-content { padding: 24px 16px 40px; }
  h1.banner { font-size: 2.4em; }
  h2.highlight, .page-content h2 { font-size: 1.9em; }
  .page-content h3 { font-size: 1.35em; }
  .hero .hero-wordmark { font-size: 3em; }
  table.digest td:first-child { white-space: normal; }
}

@media print {
  header.nav, footer.site-footer .backtotop, .skip-link { display: none; }
  .page-content { padding: 0; }
  details.doc[open] pre.doc-text, details.doc pre.doc-text { max-height: none; }
}
