/* Styles of the dashboard. The page loads no file from another host. */
/* The colors and the fonts are those of the product site. */
@font-face {
  font-family: "Lora";
  src: url("fonts/Lora-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --font-reading: "Lora", Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans CJK SC", "Hiragino Sans", "Malgun Gothic", sans-serif;
  --font-code: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --page: light-dark(oklch(0.985 0.004 262), oklch(0.17 0.022 262));
  --surface: light-dark(#ffffff, oklch(0.215 0.028 262));
  --tint: light-dark(oklch(0.955 0.02 262), oklch(0.235 0.04 262));
  --text: light-dark(oklch(0.2 0.03 262), oklch(0.95 0.008 262));
  --muted: light-dark(oklch(0.44 0.03 262), oklch(0.77 0.025 262));
  --line: light-dark(oklch(0.89 0.014 262), oklch(0.32 0.03 262));
  --accent: light-dark(#1d5fd1, #8db5ff);
  --button: light-dark(#1d5fd1, #2f6fe0);
  --danger: light-dark(#b3261e, #ffb4ab);
  --danger-fill: light-dark(#b3261e, #93000a);
  --status: light-dark(#fff4d6, #3a3115);
  --status-line: light-dark(#e2c36a, #7d6a2a);
  --good: light-dark(oklch(0.95 0.05 155), oklch(0.3 0.06 155));
  --good-line: light-dark(oklch(0.75 0.1 155), oklch(0.5 0.09 155));
  --gutter: clamp(16px, 4vw, 40px);
  --max: 920px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 16px/1.55 var(--font-body);
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1,
h2 {
  margin: 0 0 12px;
  font-family: var(--font-reading);
  font-weight: 500;
  line-height: 1.2;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.7rem, 4vw, 2.1rem);
}

h2 {
  font-size: 1.4rem;
}

/* Lora has no glyphs for Japanese, Korean, and Chinese, so those languages keep the font of the page. */
:lang(ja) :is(h1, h2),
:lang(ko) :is(h1, h2),
:lang(zh-CN) :is(h1, h2) {
  font-family: var(--font-body);
  font-weight: 650;
}

p {
  margin: 0 0 12px;
  max-width: 68ch;
  text-wrap: pretty;
}

.top {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 18px var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  color: var(--text);
  font: 600 1.2rem var(--font-reading);
  text-decoration: none;
}

.mark {
  flex: none;
  border-radius: 7px;
}

.who {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 150ms;
}

.theme:hover {
  background: color-mix(in oklch, currentColor 12%, transparent);
}

.theme .sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .moon {
    display: none;
  }

  :root:not([data-theme="light"]) .theme .sun {
    display: block;
  }
}

:root[data-theme="dark"] .theme .moon {
  display: none;
}

:root[data-theme="dark"] .theme .sun {
  display: block;
}

main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: clamp(12px, 3vw, 32px) var(--gutter) 64px;
}

section {
  margin-bottom: 44px;
}

.narrow {
  max-width: 30rem;
  margin-top: clamp(16px, 8vh, 80px);
  margin-inline: auto;
}

.lead {
  color: var(--muted);
  font-size: 1.05rem;
}

.hint {
  color: var(--muted);
  font-size: 0.92rem;
}

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

/* A message about the state of the account. The page shows it above the sections. */
.notice {
  max-width: none;
  margin-bottom: 24px;
  padding: 12px 16px;
  border: 1px solid var(--good-line);
  border-radius: 8px;
  background: var(--good);
}

.notice.warn {
  border-color: var(--status-line);
  background: var(--status);
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

input {
  flex: 1 1 14rem;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid color-mix(in oklch, var(--text) 45%, var(--page));
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input::placeholder {
  color: var(--muted);
}

#code {
  flex: 0 1 12rem;
  font-family: var(--font-code);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-weight: 600;
}

form {
  margin: 20px 0 12px;
}

button {
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: 600 1rem var(--font-body);
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

.primary {
  background: var(--button);
  color: #ffffff;
}

.primary:hover:not(:disabled) {
  background: color-mix(in oklch, var(--button) 86%, black);
}

.secondary {
  border-color: color-mix(in oklch, var(--text) 45%, var(--page));
  background: var(--surface);
  color: var(--text);
}

.secondary:hover:not(:disabled),
.quiet:hover:not(:disabled) {
  background: color-mix(in oklch, currentColor 10%, transparent);
}

.quiet {
  padding-inline: 12px;
  background: transparent;
  color: var(--text);
}

.danger {
  background: var(--danger-fill);
  color: #ffffff;
}

.small {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 0.92rem;
}

/* A button that shows more of its row keeps its label, and its fill tells that the part is open. */
button[aria-expanded="true"] {
  background: color-mix(in oklch, var(--accent) 16%, var(--surface));
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 12px;
}

/* The request of an add-on to connect. It stands out, because it needs a decision. */
.panel {
  padding: 20px clamp(16px, 3vw, 28px);
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
}

.code {
  margin: 16px 0 8px;
  font: 600 clamp(1.8rem, 7vw, 2.6rem) / 1.1 var(--font-code);
  letter-spacing: 0.12em;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px 32px;
  margin: 16px 0 20px;
}

.facts dt {
  color: var(--muted);
  font-size: 0.92rem;
}

.facts dd {
  margin: 2px 0 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.meter {
  display: block;
  height: 6px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--line);
}

.meter span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
}

.plain {
  margin: 0 0 12px;
  padding-left: 1.2em;
}

.plain li {
  margin-bottom: 4px;
}

.rows {
  margin: 16px 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.rows:empty {
  display: none;
}

.rows li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.rows .name {
  flex: 1 1 12rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.rows .meta {
  flex: 2 1 16rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.table-wrap {
  margin: 16px 0;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 10px 10px 10px 0;
  border-bottom: 1px solid var(--line);
  text-align: start;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

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

td.id {
  font-family: var(--font-code);
  font-size: 0.9rem;
}

td.id small {
  display: inline-block;
  margin-left: 8px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font: 600 0.75rem var(--font-body);
}

/* The long form of the region stays in the page for a screen reader. */
td.id .mark-long {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

td.wrap {
  min-width: 7rem;
  white-space: normal;
}

td.buttons {
  padding-right: 0;
  text-align: end;
}

td.buttons button + button {
  margin-left: 6px;
}

/* An ended share stays in the list for 30 days, in a quiet color. */
tr.ended td {
  color: var(--muted);
}

tr.stats > td {
  padding: 12px 0 20px;
  white-space: normal;
}

.stats-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  gap: 12px 48px;
}

.stats-grid table {
  width: auto;
  min-width: min(100%, 260px);
  font-size: 0.9rem;
}

.stats-grid td,
.stats-grid th {
  padding-block: 4px;
}

/* One bar for the views of one day. The longest bar is the day with the most views. */
.bar {
  display: inline-block;
  height: 8px;
  min-width: 2px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: middle;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

dialog {
  max-width: min(28rem, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}

dialog .actions {
  margin-bottom: 0;
}

footer {
  padding: 28px max(var(--gutter), calc(50% - var(--max) / 2)) 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
}

.langs ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.langs a[aria-current="page"] {
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
}

@media (max-width: 560px) {
  .who {
    display: none;
  }
}

/* On a narrow screen, each share is a block of labeled values in place of a table row. */
@media (max-width: 860px) {
  #shares thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  #shares,
  #shares tbody,
  #shares > tbody > tr,
  #shares > tbody > tr > td {
    display: block;
  }

  #shares > tbody > tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }

  #shares > tbody > tr > td {
    padding: 2px 0;
    border: 0;
    text-align: start;
    white-space: normal;
  }

  #shares > tbody > tr > td[data-label] {
    display: grid;
    grid-template-columns: minmax(6.5rem, 34%) 1fr;
    gap: 12px;
  }

  #shares > tbody > tr > td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font: 0.85rem var(--font-body);
  }

  #shares td.id small {
    padding: 0;
    border: 0;
    font-weight: 400;
    font-size: 0.85rem;
  }

  #shares td.id .mark-short {
    display: none;
  }

  #shares td.id .mark-long {
    position: static;
    width: auto;
    height: auto;
    clip-path: none;
    white-space: normal;
  }

  #shares td.buttons {
    padding-top: 10px;
  }

  #shares > tbody > tr.stats {
    padding-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
