/* Phib styles. The base element styles and tokens come from the
 * bankosegger.me look (banko.css), copied here so phib has no external CSS. */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/fonts/PlusJakartaSans-Variable.woff2") format("woff2-variations");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --phib-canvas: #1c1c1c;
  --phib-stone: #312c28;
  --phib-sand: #25221f;
  --phib-ink: #f5f3f0;
  --phib-muted: #ada59c;
  --phib-linen: #3d3732;
  --phib-accent: #f2884b;
  --phib-error: #ff6b5e;
  /* Neutral grey boxes for the short link, video and replies. */
  --phib-box: #242424;
  --phib-box-line: #303030;

  --phib-font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
    "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  --phib-hairline: inset 0 0 0 1px var(--phib-stone);
  --phib-ease: cubic-bezier(0.2, 0, 0, 1);

  color-scheme: dark;
}

/* Base ------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--phib-linen) transparent;
}

body {
  margin: 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--phib-canvas);
  color: var(--phib-ink);
  font-family: var(--phib-font);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "calt", "rlig";
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: #f2884b33;
}

:focus-visible {
  outline: 1.5px solid var(--phib-accent);
  outline-offset: 2px;
  border-radius: 6px;
}

h1,
h2 {
  color: var(--phib-ink);
  font-weight: 700;
  letter-spacing: -0.006em;
  line-height: 1.25;
}

h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 1rem;
}

p {
  margin: 0 0 1.25em;
}

a {
  color: var(--phib-accent);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

a:hover {
  text-decoration: underline;
}

img,
video,
svg {
  max-width: 100%;
  height: auto;
}

/* Forms ------------------------------------------------------------------ */

button {
  -webkit-appearance: none;
  appearance: none;
  background: var(--phib-canvas);
  border: 0;
  box-shadow: var(--phib-hairline);
  color: var(--phib-muted);
  font: 700 0.91rem/1.2 var(--phib-font);
  padding: 7px 14px;
  border-radius: 9999px;
  cursor: pointer;
  transition:
    transform 0.14s var(--phib-ease),
    background 0.16s ease,
    color 0.16s ease;
}

button:hover {
  background: var(--phib-sand);
  color: var(--phib-ink);
}

button:active {
  transform: scale(0.96);
}

button[disabled],
input[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

input[type="url"],
input[type="password"],
input[type="search"] {
  background: var(--phib-canvas);
  border: 1px solid var(--phib-stone);
  color: var(--phib-ink);
  font-family: var(--phib-font);
  font-size: 0.945rem;
  padding: 8px 12px;
  border-radius: 4px;
  min-height: 34px;
  transition: border-color 0.16s ease;
}

input:focus {
  outline: none;
  border-color: var(--phib-accent);
}

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--phib-stone);
  border-radius: 6px;
  background: var(--phib-canvas);
  display: inline-grid;
  place-items: center;
  vertical-align: middle;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

input[type="checkbox"]:checked {
  background: var(--phib-accent);
  border-color: var(--phib-accent);
}

input[type="checkbox"]:checked::after {
  content: "✓";
  color: #fff;
  font-size: 0.84rem;
  line-height: 1;
}

label {
  color: var(--phib-muted);
  font-size: 0.875rem;
}

/* 16px keeps iOS Safari from zooming in when a field gains focus. */
@media (max-width: 685px) {
  input {
    font-size: 16px;
  }
}

/* Phib ------------------------------------------------------------------- */

.result,
.tweet,
.comments {
  background: var(--phib-box);
  box-shadow: inset 0 0 0 1px var(--phib-box-line);
  border-radius: 8px;
}


[hidden] {
  display: none !important;
}

.card {
  width: 100%;
  min-width: 0;
  max-width: 440px;
  padding: 2.5rem;
  background: transparent;
  border: none;
}

.card h1 {
  margin: 0 0 0.4rem;
}

.dot {
  color: var(--phib-accent);
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--phib-muted);
  font-size: 0.875rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.row input {
  flex: 1;
  min-width: 0;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--phib-muted);
  font-size: 0.8125rem;
  cursor: pointer;
}

.error {
  color: var(--phib-error);
  font-size: 0.8125rem;
  margin: 0.875rem 0 0;
}

.result {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
}

.result a {
  flex: 1;
  color: var(--phib-ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result a:hover {
  text-decoration: underline;
}

.copy-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  flex-shrink: 0;
  background: transparent;
  box-shadow: var(--phib-hairline);
  color: var(--phib-muted);
  transition: box-shadow 0.15s ease, transform 0.1s ease, color 0.15s ease;
}

.copy-btn:hover {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--phib-muted);
  color: var(--phib-ink);
}

.copy-btn:active {
  transform: scale(0.9);
}

.copy-btn .icon {
  width: 15px;
  height: 15px;
}

.copy-btn .icon-check {
  display: none;
  color: var(--phib-accent);
}

.copy-btn.copied .icon-copy {
  display: none;
}

.copy-btn.copied .icon-check {
  display: block;
  animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.copy-btn.copied {
  box-shadow: inset 0 0 0 1px var(--phib-accent);
}

@keyframes pop {
  0% {
    transform: scale(0.3) rotate(-30deg);
    opacity: 0;
  }
  60% {
    transform: scale(1.25) rotate(6deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--phib-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--phib-accent);
}

.copy-btn.copied .tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* With a Twitter video showing, the card widens and the replies sit in a
 * column to the right of the video. */
.card:has(.tweet-layout:not([hidden])) {
  max-width: 1200px;
}

.tweet-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* The replies column takes the height of the video column and scrolls inside;
 * size containment stops its own content from making the row taller. */
.tweet-layout .comments {
  contain: size;
  min-height: 360px;
  display: flex;
  flex-direction: column;
}

.tweet-layout .comments-list {
  flex: 1;
  min-height: 0;
  max-height: none;
}

@media (max-width: 860px) {
  .tweet-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .tweet-layout .comments {
    contain: none;
    min-height: 0;
  }

  .tweet-layout .comments-list {
    max-height: 60vh;
  }
}

@media (max-width: 520px) {
  .card {
    padding: 1.5rem 0;
  }
}

.tweet {
  align-self: start;
  padding: 0.75rem;
}

/* --ratio (width / height) is set from the tweet so the player keeps its size
 * before the video loads; tall videos get narrower to stay within 75vh. */
.tweet-video {
  display: block;
  aspect-ratio: var(--ratio, 16 / 9);
  width: min(100%, calc(75vh * var(--ratio, 16 / 9)));
  margin: 0 auto 0.75rem;
  background: #000;
  border-radius: 4px;
}

.tweet-author {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tweet-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tweet-name {
  display: block;
  color: var(--phib-ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.8125rem;
  line-height: 1.2;
}

.tweet-name:hover {
  text-decoration: underline;
}

.tweet-handle {
  color: var(--phib-muted);
  font-size: 0.75rem;
}

.tweet-text {
  margin: 0.625rem 0 0;
  font-size: 0.8125rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.tweet-meta {
  margin: 0.5rem 0 0;
  color: var(--phib-muted);
  font-size: 0.75rem;
}

.tweet-meta a {
  color: var(--phib-muted);
}

.tweet-meta a:hover {
  color: var(--phib-ink);
}

.comments {
  padding: 0.75rem;
}

.comments-title {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
}

.comments-status {
  margin: 0;
  color: var(--phib-muted);
  font-size: 0.75rem;
}

.comments-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 75vh;
  overflow-y: auto;
}

.comment {
  display: flex;
  gap: 0.5rem;
  padding: 0.625rem 0;
  border-top: 1px solid var(--phib-box-line);
}

.comment:first-child {
  border-top: none;
  padding-top: 0;
}

.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.comment-body {
  min-width: 0;
}

.comment-head {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
  min-width: 0;
}

.comment-name {
  color: var(--phib-ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.comment-name:hover {
  text-decoration: underline;
}

.comment-handle,
.comment-likes {
  color: var(--phib-muted);
  font-size: 0.6875rem;
  white-space: nowrap;
}

.comment-text {
  margin: 0.125rem 0 0.25rem;
  font-size: 0.8125rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.comments-more {
  display: block;
  margin-top: 0.5rem;
  color: var(--phib-muted);
  font-size: 0.75rem;
}

.comments-more:hover {
  color: var(--phib-ink);
}

.watch-title {
  color: inherit;
  text-decoration: none;
}

.subtitle a {
  color: var(--phib-muted);
}

.subtitle a:hover {
  color: var(--phib-ink);
}

.history {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  max-height: 340px;
  overflow-y: auto;
  border: none;
}

.history:empty {
  border-top: none;
  margin-top: 0;
}

.history li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.125rem;
}

.history-thumb {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 6px;
  background: var(--phib-box);
  box-shadow: inset 0 0 0 1px var(--phib-box-line);
  color: var(--phib-muted);
}

.history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-thumb svg {
  width: 16px;
  height: 16px;
}

.history-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-time {
  color: var(--phib-muted);
  font-size: 0.6875rem;
  white-space: nowrap;
}

.history li:last-child {
  border-bottom: none;
}

.history a {
  color: var(--phib-ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.history a:hover {
  text-decoration: underline;
}

.history .target {
  color: var(--phib-muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clear-btn {
  display: block;
  margin: 0.5rem 0 0 auto;
  padding: 4px 12px;
  font-size: 0.75rem;
}

/* Admin ------------------------------------------------------------------ */

.card.admin {
  max-width: 1000px;
}

.admin-stats {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.admin-stat {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--phib-box);
  box-shadow: inset 0 0 0 1px var(--phib-box-line);
  color: var(--phib-muted);
  font-size: 0.8125rem;
}

.admin-stat span {
  display: block;
  color: var(--phib-ink);
  font-size: 1.5rem;
  font-weight: 800;
}

.admin-tools {
  margin-bottom: 0.75rem;
}

.admin-tools input {
  flex: 1;
  min-width: 0;
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.admin-table th,
.admin-table td {
  padding: 0.5rem 0.625rem;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--phib-box-line);
}

.admin-table th {
  color: var(--phib-muted);
  font-size: 0.8125rem;
  font-weight: 700;
}

.admin-table .num {
  text-align: right;
}

.admin-target {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-target a {
  color: var(--phib-ink);
}

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

.sort-btn {
  padding: 0;
  background: none;
  box-shadow: none;
  font: inherit;
  color: inherit;
  border-radius: 0;
}

.sort-btn:hover {
  background: none;
}

.sort-btn[data-active="asc"]::after {
  content: " ↑";
}

.sort-btn[data-active="desc"]::after {
  content: " ↓";
}

.delete-btn {
  padding: 4px 10px;
  font-size: 0.8125rem;
}

.delete-btn:hover {
  color: var(--phib-error);
}

.admin-empty {
  margin-top: 1rem;
  color: var(--phib-muted);
  font-size: 0.875rem;
}

@media (max-width: 520px) {
  .admin-stats {
    flex-direction: column;
  }
}
