/* Blink - Lightweight RSS Reader */

/* === CSS Custom Properties === */
:root {
  --bg: #1c2122;
  --text: #e8e8e8;
  --muted: #a8a8a8;
  --accent: #a2faa3;
  --surface: #252c2d;
  --border: #2d3637;
  --shadow: rgba(0,0,0,.3);
  --visited: #8fd883;
  --ff: ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, monospace;
  --r: 10px;
  --header-h: 56px;
  color-scheme: dark light;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f7f8;
    --text: #1c1f24;
    --muted: #3c434d;
    --accent: #2a7ea2;
    --surface: #fff;
    --border: #e3e5e8;
    --shadow: rgba(0,0,0,.06);
    --visited: #6c3fa4;
  }
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font: 400 1rem/1.6 var(--ff);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding: env(safe-area-inset-top, 12px) env(safe-area-inset-right, 12px) calc(env(safe-area-inset-bottom, 0) + 90px) env(safe-area-inset-left, 12px);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
a:visited { color: var(--visited); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* === Layout === */
#feed {
  max-width: 800px;
  margin-inline: auto;
  padding-block-start: calc(env(safe-area-inset-top, 0) + 20px);
}

@media (display-mode: standalone) {
  body {
    padding-block-start: calc(env(safe-area-inset-top, 0px));
  }
  #feed {
    padding-block-start: 0;
  }
}

/* === Feed Items === */
.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--r);
  padding-block-end: 48px;
  margin-block-end: 16px;
  box-shadow: 0 2px 8px var(--shadow);
  content-visibility: auto;
  contain-intrinsic-size: 200px;
  position: relative;
  transition: border-color .15s, box-shadow .15s;
}
.item:focus { outline: none; }
.item.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 40%, transparent), 0 2px 8px var(--shadow);
}

.item h2 {
  font-size: 1.15rem;
  font-weight: 500;
  margin-block-end: 12px;
  word-break: break-word;
}

.meta {
  position: absolute;
  bottom: 12px;
  left: 10px;
  right: 76px;
  font-size: .8rem;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  overflow: hidden;
}
.source {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta-sep { opacity: .5; flex-shrink: 0; }
.time { opacity: .75; flex-shrink: 0; }

/* === Description Text === */
.desc {
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.5;
  margin-block-start: 8px;
  padding-block-end: 60px;
}
.item.show-desc .desc { display: block; }
.item:not(.show-desc) .desc { display: none; }

/* === Item Actions (star + expand buttons) === */
.item-actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 8px;
}

.expand-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: .9rem;
  color: var(--muted);
  cursor: pointer;
  transition: transform .12s, color .12s;
}

.star {
  width: 50px;
  height: 50px;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  color: var(--muted);
  cursor: pointer;
  transition: transform .12s, color .12s;
}
.expand-btn:hover, .star:hover { color: var(--accent); }
.expand-btn:active, .star:active { transform: scale(.95); }

.star.starred { color: #e4626f; animation: pop .3s ease; }
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* === Separator === */
.sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-block: 24px;
  font-size: .8rem;
  color: var(--muted);
}
.sep::before, .sep::after { content: ''; flex: 1; border-block-end: 1px solid var(--border); }
.sep-heart { color: #e4626f; font-size: 1rem; }

/* === Update Date Header === */
.update-header {
  text-align: center;
  font-size: .9rem;
  color: var(--muted);
  padding: 12px 0 20px;
}

/* === Layout === */
#feed {
  max-width: 800px;
  margin-inline: auto;
}

/* === Floating Buttons === */
#floating-buttons {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0) + 16px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  transition: opacity .3s, transform .3s;
}

#floating-buttons.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.floating-left { margin-right: auto; }
.floating-center { margin: 0 auto; }
.floating-right { margin-left: auto; }

.floating-btn {
  width: 50px;
  height: 50px;
  padding: 10px;
  background: var(--surface);
  color: var(--accent);
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .12s, transform .12s;
  box-shadow: 0 4px 12px var(--shadow);
}
.floating-btn:hover { background: color-mix(in oklab, var(--surface) 92%, var(--accent) 8%); }
.floating-btn:active { transform: scale(.95); }
.floating-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.floating-btn svg { width: 30px; height: 30px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* === Footer Bar (hidden, kept for reference) === */
.bar {
  display: none;
}
.bar-left, .bar-right { display: none; }
.bar-center { display: none; }
.bar-left, .bar-right { display: flex; gap: 8px; align-items: center; }
.bar-center { font-size: .8rem; color: var(--muted); }

/* === Icon Buttons === */
.btn {
  appearance: none;
  border: 1px solid #a8a8a8;
  background: var(--surface);
  color: var(--accent);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .12s, transform .12s;
}
.btn:hover { background: color-mix(in oklab, var(--surface) 92%, var(--accent) 8%); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* === Video Placeholder === */
.video {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 6px;
  margin-block-end: 10px;
  overflow: hidden;
  cursor: pointer;
}
.video img { width: 100%; height: 100%; object-fit: cover; }

.thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 6px;
  margin-block-end: 10px;
}

.video .play {
  position: absolute;
  bottom: 8px;
  left: 8px;
  width: 32px;
  height: 32px;
  background: rgba(255,0,0,.55);
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.video .play::before {
  content: '';
  border-block: 7px solid transparent;
  border-inline-start: 12px solid #fff;
  margin-inline-start: 3px;
}
.video:hover .play { background: rgba(255,0,0,.7); }
.video.loaded img, .video.loaded .play { display: none; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; }

/* === Modals === */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-content {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r);
  box-shadow: 0 4px 24px var(--shadow);
  padding: 24px;
  width: min(90vw, 400px);
  max-height: 80vh;
  overflow-y: auto;
}
.modal h2 { margin-block-end: 16px; font-size: 1.2rem; color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-block-start: 16px; }

/* === Form Elements === */
label { display: block; margin-block-start: 12px; margin-block-end: 4px; font-size: .9rem; color: var(--muted); }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint {
  font-size: .75rem;
  color: var(--muted);
  margin-block-start: 8px;
  text-align: center;
}
.hint code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-family: var(--mono); }

/* === Status Messages === */
.status {
  padding: 8px 12px;
  border-radius: 6px;
  margin-block-end: 12px;
  font-size: .8rem;
  display: none;
}
.status.error { display: block; background: rgba(191,97,106,.2); color: #bf616a; border: 1px solid #bf616a; }
.status.success { display: block; background: rgba(163,190,140,.2); color: #a3be8c; border: 1px solid #a3be8c; }
.status.info { display: block; background: rgba(136,192,208,.2); color: var(--accent); border: 1px solid var(--accent); }

/* === Setup Form === */
#setup-form {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  background: var(--bg);
  padding: 24px;
}

.setup-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: 0 4px 24px var(--shadow);
  padding: 32px 24px;
  width: min(90vw, 360px);
  text-align: center;
}

.setup-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  border-radius: 16px;
}

.setup-content h2 {
  margin-block-end: 8px;
  font-size: 1.4rem;
  color: var(--accent);
}

.setup-desc {
  font-size: .9rem;
  color: var(--muted);
  margin-block-end: 20px;
  line-height: 1.5;
}

.setup-fields {
  text-align: left;
  margin-block-end: 16px;
}

.setup-fields input {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.setup-fields input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.setup-fields input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.setup-btn {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  margin-block-start: 8px;
}

/* === Toast Notifications === */
#toast-container {
  position: fixed;
  bottom: calc(90px + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 18px;
  font-size: .8rem;
  box-shadow: 0 4px 16px var(--shadow);
  pointer-events: auto;
  animation: toastIn .3s ease;
  max-width: 90vw;
}
.toast.out { animation: toastOut .25s ease forwards; }
.toast.success { border-color: #a3be8c; color: #a3be8c; }
.toast.error { border-color: #bf616a; color: #bf616a; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(12px); } }

/* === Scroll to Top (now part of floating buttons) === */
#scroll-top { display: none; }
#scroll-top-right { display: none; }

/* === Keyboard Help === */
#keyboard-help {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
#keyboard-help kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--accent);
}
#keyboard-help li { display: flex; align-items: center; gap: 10px; margin-block-end: 8px; }
#keyboard-help .desc { color: var(--muted); font-size: .9rem; }

/* === Empty State === */
#empty { display: none; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; text-align: center; color: var(--muted); }
#empty .icon { font-size: 2.5rem; opacity: .4; margin-block-end: 12px; }
#empty .title { font-size: 1.1rem; font-weight: 500; margin-block-end: 4px; }
#empty .sub { font-size: .9rem; opacity: .65; }

/* === Loading Skeleton === */
#loading .skeleton { max-width: 800px; margin-inline: auto; padding-block-start: env(safe-area-inset-top, 12px); }
#loading .skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--r);
  margin-block-end: 16px;
  overflow: hidden;
}
#loading .skeleton-media {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 6px;
  margin-block-end: 10px;
  background: linear-gradient(90deg, var(--border) 25%, color-mix(in oklab, var(--border) 60%, var(--surface)) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
#loading .skeleton-title {
  height: 18px;
  width: 70%;
  border-radius: 4px;
  margin-block-end: 8px;
  background: linear-gradient(90deg, var(--border) 25%, color-mix(in oklab, var(--border) 60%, var(--surface)) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
#loading .skeleton-meta {
  height: 12px;
  width: 35%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--border) 25%, color-mix(in oklab, var(--border) 60%, var(--surface)) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
