/*
 * TipTopTap styles. One accent (the logo orange) for primary buttons only.
 * Ink is used for links, selected states and focus rings. Values are never coloured.
 * Every control on a row has the same height (--control-h) and radius (--radius).
 */

@font-face {
  font-family: "CeraPro";
  src: url("CeraPro-Medium.otf") format("opentype");
  font-weight: 400 600;
  font-display: swap;
}

@font-face {
  font-family: "CeraPro";
  src: url("CeraPro-Black.otf") format("opentype");
  font-weight: 700 900;
  font-display: swap;
}

:root {
  --ink: #16181d;
  --muted: #5b626e;
  --line: #d5d9df;
  --bg: #ffffff;
  --surface: #f4f5f7;
  --accent: #ffa500;
  --accent-ink: #16181d;
  --danger: #b42318;
  --control-h: 44px;
  --radius: 8px;
  --gap: 16px;
  --font: "CeraPro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --ink: #eceef1;
  --muted: #a4abb6;
  --line: #3b4048;
  --bg: #121417;
  --surface: #1d2025;
  --danger: #ff8a7a;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

h1,
h2,
h3 {
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 var(--gap);
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.25rem;
  margin-top: 32px;
}

h3 {
  font-size: 1rem;
  margin: 20px 0 4px;
}

p {
  margin: 0 0 var(--gap);
}

a {
  color: var(--ink);
  text-underline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Parts that need JavaScript, and the fallbacks without it. theme-init.js sets the "js" class. */
.no-js .js-only,
.js .no-js-only {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  z-index: 10;
}

.skip-link:focus {
  top: 8px;
}

/* Layout */

.container {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 var(--gap);
}

.page {
  padding-top: 24px;
  padding-bottom: 48px;
}

.narrow {
  max-width: 420px;
}

.prose {
  max-width: 680px;
}

/* Top bar */

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: var(--gap);
  min-height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.125rem;
  text-decoration: none;
  margin-right: auto;
}

.brand img {
  width: 28px;
  height: 28px;
}

.mainnav {
  display: none;
  gap: 4px;
}

.mainnav a {
  display: flex;
  align-items: center;
  height: var(--control-h);
  padding: 0 12px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}

.mainnav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--ink);
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
}

[data-theme="dark"] .icon-moon,
:root:not([data-theme="dark"]) .icon-sun {
  display: none;
}

/* Bottom tab bar on small screens */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
  min-width: 0;
}

.tabbar span {
  max-width: 100%;
  padding: 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabbar svg {
  width: 22px;
  height: 22px;
}

.tabbar a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

body {
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
}

@media (min-width: 760px) {
  .mainnav {
    display: flex;
  }

  .tabbar {
    display: none;
  }

  body {
    padding-bottom: 0;
  }
}

.footer {
  padding: 24px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

/* Controls: fields, buttons and segmented choices share one height and radius */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label,
.field .label {
  font-size: 0.875rem;
  font-weight: 600;
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
  align-items: end;
}

.control {
  width: 100%;
  height: var(--control-h);
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  appearance: none;
}

select.control {
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.control[aria-invalid="true"] {
  border-color: var(--danger);
}

/* A calculated value: the shape of an input, read-only, neutral background */
.result {
  display: flex;
  align-items: center;
  background: var(--surface);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.result-main {
  font-size: 1.25rem;
  font-weight: 800;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-h);
  padding: 0 16px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.btn-danger {
  color: var(--danger);
}

.btn-block {
  width: 100%;
}

.segmented {
  display: inline-flex;
  height: var(--control-h);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label,
.segmented a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 0 12px;
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.segmented label + label,
.segmented a + a {
  border-left: 1px solid var(--line);
}

.segmented label:has(input:checked),
.segmented a[aria-current="true"] {
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}

.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: -4px;
}

.segmented-small {
  height: 36px;
}

.segmented-small a {
  min-width: 40px;
  font-size: 0.875rem;
}

.error-text {
  color: var(--danger);
  margin: 0;
}

.alert {
  padding: 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 28px;
  min-width: 0;
}

legend {
  width: 100%;
  padding: 0 0 8px;
  margin-bottom: var(--gap);
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}

/* Calculator layout: inputs, and the result next to them on wide screens */

.calc {
  display: grid;
  gap: 28px;
}

.calc-result {
  display: grid;
  gap: var(--gap);
  align-content: start;
  padding: var(--gap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

@media (min-width: 900px) {
  .calc {
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
  }

  .calc-result {
    position: sticky;
    top: 16px;
  }
}

.tapbar {
  display: flex;
  gap: 8px;
  align-items: end;
  margin-bottom: 24px;
}

.tapbar .field {
  flex: 1;
  max-width: 320px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Beer search (combobox) */

.combobox {
  position: relative;
}

.listbox {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 6;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}

.listbox li {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: var(--control-h);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.listbox li[aria-selected="true"],
.listbox li:hover {
  background: var(--surface);
}

.listbox .option-sub {
  font-size: 0.875rem;
  color: var(--muted);
}

.listbox .empty {
  color: var(--muted);
  cursor: default;
}

/* Tables (statistics) */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 8px 4px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--gap);
  margin-bottom: 32px;
}

.kpi {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

dl dt {
  font-weight: 600;
  margin-top: 12px;
}

dl dd {
  margin: 0;
}

.fields-single {
  grid-template-columns: 1fr;
}

/* On small screens the pressure stays visible above the tab bar while the user types. */
.result-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(56px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  min-height: 48px;
  padding: 0 var(--gap);
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 4;
}

.result-bar strong {
  font-size: 1.125rem;
  font-weight: 800;
}

body:has(.result-bar) {
  padding-bottom: calc(104px + env(safe-area-inset-bottom));
}

@media (min-width: 900px) {
  .result-bar {
    display: none;
  }
}

@media (min-width: 760px) and (max-width: 899px) {
  .result-bar {
    bottom: 0;
  }

  body:has(.result-bar) {
    padding-bottom: 48px;
  }
}

.field .segmented label {
  flex: 1;
}

/* Dashboard, sign-up and branded pages */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--gap);
}

.page-head h1 {
  margin: 0;
}

/* A neutral outlined label, for example the plan or "checked by the brewery". */
.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  font-size: 0.8125rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  white-space: nowrap;
}

.listbox .tag {
  align-self: flex-start;
  margin-top: 4px;
}

.subnav {
  margin-bottom: 24px;
}

.panel {
  padding: var(--gap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel h2 {
  margin-top: 0;
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.input-row {
  display: flex;
  gap: 8px;
}

textarea.control {
  height: auto;
  min-height: var(--control-h);
  padding: 10px 12px;
  resize: vertical;
}

.control.code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8125rem;
}

input[type="file"].control {
  padding: 9px 12px;
}

.logo-preview {
  display: block;
  max-width: 200px;
  height: 48px;
  object-fit: contain;
  margin-bottom: 8px;
}

.brand-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-weight: 700;
}

.brand-head img {
  max-width: 160px;
  object-fit: contain;
}

.table-compact {
  max-width: 420px;
}

.page-embed {
  padding-top: 16px;
}

/* Prices, billing and footer */

.lead {
  max-width: 640px;
  font-size: 1.0625rem;
  color: var(--muted);
}

.plans {
  display: grid;
  gap: var(--gap);
  margin: 24px 0 32px;
}

@media (min-width: 760px) {
  .plans {
    grid-template-columns: 1fr 1fr;
    max-width: 860px;
  }
}

.plans .panel {
  display: flex;
  flex-direction: column;
}

.plans .panel ul {
  flex: 1;
  padding-left: 20px;
}

.plan-price {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 800;
}

.choice-list {
  display: grid;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--control-h);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.choice span:nth-of-type(2) {
  margin-left: auto;
}

.choice:has(input:checked) {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-links a {
  color: var(--muted);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--ink);
}

/* Troubleshooter */

.chat {
  max-width: 720px;
}

.chat-log {
  list-style: none;
  margin: 0 0 var(--gap);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-log li {
  padding: 12px var(--gap);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chat-log .chat-user {
  background: var(--surface);
}

.chat-who {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

.chat-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-status:empty {
  display: none;
}

.chat-form .actions {
  margin-top: 8px;
}

.chat-note {
  margin-top: var(--gap);
  font-size: 0.875rem;
}

.brand-ai {
  margin-top: var(--gap);
}
