/* SCRN web UI. Two themes via CSS variables; the server sets data-theme on
   <html>, so the right theme is there before the first paint. */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #323844;
  --text: #e6e8eb;
  --muted: #a3a9b3;
  --accent: #34e58c;
  --accent-text: #0b1f16;
  --danger: #ff8a80;
  --danger-bg: #3a1d1c;
  --ok: #7ddc9b;
  --ok-bg: #183324;
  --focus: #ffd166;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eceef2;
  --border: #c9ced6;
  --text: #15181d;
  --muted: #4f5661;
  /* The darker brand green: #0e9f58 would miss 4.5:1 on white. */
  --accent: #0a7a44;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fbe9e7;
  --ok: #17663a;
  --ok-bg: #e3f4e9;
  --focus: #8a4b00;
}

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

html {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 100%;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
}

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

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  z-index: 10;
}

.skip-link:focus {
  top: 0.5rem;
}

/* Top bar */

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

.topbar-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  color: var(--text);
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  margin-left: auto;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.35rem 0.1rem;
  border-bottom: 2px solid transparent;
}

.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.nav form {
  margin: 0;
}

/* The account name, set apart from the menu links by a divider. */
.nav-user {
  padding-left: 1rem;
  margin-left: 0.25rem;
  border-left: 1px solid var(--border);
  font-weight: 600;
  color: var(--text);
}

/* Layout */

main {
  flex: 1;
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

main.narrow {
  max-width: 28rem;
}

h1 {
  font-size: 1.6rem;
  margin: 0.5rem 0 1.25rem;
}

h2 {
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

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

.hint {
  display: block;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

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

.footer-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.footer-brand {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.version {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.repo-link {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
}

.repo-link:hover,
.repo-link:focus-visible {
  color: var(--text);
}

.repo-link svg {
  fill: currentColor;
}

/* Forms */

.field {
  margin-bottom: 1rem;
}

label,
legend {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 1.25rem;
  font-weight: 400;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  max-width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
}

input.short,
select.short {
  width: auto;
  min-width: 8rem;
}

td input.short {
  width: 7rem;
  min-width: 0;
}

.inline-form + .table-wrap,
.inline-form + p {
  margin-top: 1.25rem;
}

input[readonly] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2);
}

input[type="radio"],
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1.1rem;
  height: 1.1rem;
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.5rem 1rem;
}

button:hover {
  filter: brightness(1.1);
}

button.secondary {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

button.danger {
  color: var(--danger);
  background: transparent;
  border-color: var(--danger);
}

button.small {
  font-size: 0.875rem;
  padding: 0.25rem 0.6rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin: 0;
}

.inline-form .field {
  margin: 0;
}

/* Several small forms side by side, e.g. the actions of a table row. */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.actions form {
  margin: 0;
}

/* Messages */

.alert,
.notice {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.alert {
  color: var(--danger);
  background: var(--danger-bg);
}

.notice {
  color: var(--ok);
  background: var(--ok-bg);
}

.notice input {
  margin-top: 0.5rem;
  color: var(--text);
}

/* Tables */

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

td form {
  margin: 0;
}

.badge {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* Storage usage */

.usage {
  display: grid;
  gap: 0.35rem;
}

progress {
  width: 100%;
  max-width: 24rem;
  height: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  appearance: none;
}

progress::-webkit-progress-bar {
  background: var(--surface-2);
}

progress::-webkit-progress-value {
  background: var(--accent);
}

progress::-moz-progress-bar {
  background: var(--accent);
}

@media (max-width: 40rem) {
  .nav {
    margin-left: 0;
  }

  th,
  td {
    padding: 0.45rem 0.4rem;
  }
}

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

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

/* Gallery */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filters a,
a.button {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.filters a[aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

a.button {
  border-radius: 6px;
  font-weight: 600;
}

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
}

.shot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.thumb-link {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  overflow: hidden;
}

.thumb-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.shot-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.5rem;
  padding: 0.6rem 0.75rem 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.meta-start {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* The date wraps as a whole and stays on the right. */
.shot-meta time {
  white-space: nowrap;
  margin-left: auto;
}

.views {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.views svg {
  fill: currentColor;
  flex: none;
}

.badge.public {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok);
}

.copy-row {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem 0;
}

.copy-row input {
  min-width: 0;
  flex: 1;
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
}

.short-code {
  flex: 1;
  min-width: 0;
  align-self: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.short-code:hover,
.short-code:focus-visible {
  color: var(--accent);
}

/* The custom expiry field only shows while "custom" is chosen. Browsers
   without :has() always show it. */
form:has(select[name="expiry"] option[value="custom"]:not(:checked)) .expiry-custom {
  display: none;
}

/* Off-screen text field for the copy fallback without HTTPS. */
.copy-buffer {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

.shot-card > :last-child {
  padding-bottom: 0.75rem;
}

.more-slot {
  grid-column: 1 / -1;
  text-align: center;
  padding: 0.5rem 0;
}

/* Detail view */

.shot-detail {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.shot-image {
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
}

.shot-image img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1rem;
}

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

.facts dd {
  margin: 0;
}

.card .copy-row {
  padding: 0;
}

.label {
  font-weight: 600;
  margin: 0 0 0.3rem;
}

details summary {
  cursor: pointer;
  color: var(--danger);
  font-weight: 600;
}

details[open] summary {
  margin-bottom: 0.75rem;
}

@media (max-width: 56rem) {
  .shot-detail {
    grid-template-columns: 1fr;
  }
}

/* Phones: tables become one card per row, with the column name in front
   of every value. */
@media (max-width: 40rem) {
  table.stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  table.stack,
  table.stack tbody,
  table.stack tr,
  table.stack td {
    display: block;
    width: 100%;
  }

  table.stack tr {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0;
  }

  table.stack td {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    border: 0;
    padding: 0.3rem 0;
  }

  table.stack td::before {
    content: attr(data-label);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
  }

  table.stack td:empty {
    display: none;
  }

  table.stack .usage {
    flex: 1 1 12rem;
    justify-items: end;
  }

  .copy-row input {
    font-size: 1rem;
  }
}

/* Touch screens: comfortable tap targets. */
@media (pointer: coarse) {
  button,
  a.button,
  .filters a,
  .nav a {
    min-height: 2.75rem;
  }

  .nav a,
  .filters a {
    display: inline-flex;
    align-items: center;
  }
}

/* Passkeys */

.passkey-login,
.passkey-confirm {
  margin-top: 1.25rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.passkey-login .alert,
.passkey-confirm .alert {
  margin-top: 0.75rem;
}

#passkeys .alert[data-passkey-message] {
  margin-top: 1rem;
}
