/* Phone layout around the reader. The article itself is styled by
   reader.css (the extension's sidepanel.css, copied in at build time), so
   this file only covers what the side panel doesn't have: an app header,
   the article list, settings, and the bottom sheet that replaces the
   panel's hover popover and pinned banner. */

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

body {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* While the definition sheet is open, leave room to scroll the last lines
   of the article clear of it. */
body.sheet-open {
  padding-bottom: 45vh;
}

.muted {
  color: #777;
  font-size: 13px;
}

/* Header ------------------------------------------------------------------ */

#app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px;
  gap: 8px;
}

#app-header h1 {
  flex: 1;
  font-size: 17px;
  text-align: center;
}

.header-btn {
  width: 40px;
  height: 36px;
  border: none;
  background: none;
  color: #f5e6c8;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

/* An invisible placeholder keeps the title centred when one side's button
   is hidden. */
.header-btn.hidden {
  display: block;
  visibility: hidden;
}

/* Shared buttons ----------------------------------------------------------- */

.pill-btn,
.primary-btn {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 18px;
  border: 1px solid #d8d8d8;
  background: #fff;
  color: #1a1a1a;
}

.pill-btn:disabled {
  opacity: 0.4;
}

.pill-btn.danger {
  color: #b91c1c;
  border-color: #e7b4b4;
}

.primary-btn {
  border-color: #b91c1c;
  background: #b91c1c;
  color: #fff;
  font-weight: 600;
}

/* List view ----------------------------------------------------------------- */

#list-view {
  padding: 12px 16px 24px;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

#sync-status.error {
  color: #b91c1c;
}

#article-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#article-list li + li {
  margin-top: 10px;
}

.article-card {
  display: block;
  position: relative;
  overflow: hidden;
  padding: 12px 14px 14px;
  border: 1px solid #e6e6e6;
  border-radius: 10px;
  background: #fff;
  color: inherit;
  text-decoration: none;
}

.card-title {
  font-family: var(--zh-font);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
}

.card-subtitle {
  margin-top: 2px;
  font-size: 13px;
  color: #555;
}

.card-meta {
  margin-top: 6px;
  font-size: 12px;
  color: #888;
}

/* How far through the article the reader got. */
.card-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: calc(var(--progress) * 100%);
  background: #b91c1c;
}

.empty {
  margin-top: 40px;
  text-align: center;
  color: #777;
  line-height: 1.5;
}

.empty a {
  color: #b91c1c;
}

/* Reader -------------------------------------------------------------------- */

#reader-controls {
  position: sticky;
  top: calc(52px + env(safe-area-inset-top));
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #fafafa;
  border-bottom: 1px solid #e6e6e6;
}

.level-chip {
  font-size: 12px;
  font-weight: 600;
  color: #b91c1c;
  border: 1px solid #e7b4b4;
  border-radius: 10px;
  padding: 2px 8px;
}

/* Touch-sized versions of the panel's stepper. */
#reader-controls .stepper-btn {
  width: 36px;
  height: 32px;
  font-size: 18px;
}

#reader-controls .stepper-value {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-width: 48px;
  padding: 0 2px;
  font-size: 13px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  margin-left: auto;
}

.toggle input {
  width: 18px;
  height: 18px;
}

#result {
  padding: 16px;
}

/* No hover on touch screens: a sticky tint left behind on the last word
   tapped would look like a second selection. */
@media (hover: none) {
  .word:hover {
    background: none;
  }
}

/* Tap targets for the gloss toggles. */
.english-toggle {
  font-size: 13px;
  padding: 6px 0;
}

.english {
  font-size: 14px;
  line-height: 1.5;
}

#reader-source {
  padding: 0 16px 32px;
}

#reader-source a {
  color: #b91c1c;
}

/* Word sheet ------------------------------------------------------------------ */

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  max-height: 45vh;
  overflow-y: auto;
  padding: 16px 48px calc(18px + env(safe-area-inset-bottom)) 18px;
  background: #fffdf5;
  border-top: 1px solid #e8dcc0;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.12);
}

.sheet.hidden {
  display: none;
}

.sheet-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 24px;
  color: #999;
}

.sheet .entry-word {
  font-size: 26px;
}

.sheet .entry-pinyin,
.sheet .entry-gloss {
  font-size: 16px;
}

.sheet .entry-save {
  font-size: 13px;
  padding: 5px 12px;
}

/* Settings ---------------------------------------------------------------------- */

#settings-view {
  padding: 8px 16px 32px;
}

#settings-view h2 {
  font-size: 15px;
  margin: 22px 0 6px;
}

#settings-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  font-size: 13px;
  color: #555;
}

#settings-form input {
  font: inherit;
  font-size: 16px; /* 16px or more stops iOS zooming in on focus */
  padding: 9px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  background: #fff;
}

#settings-form .primary-btn {
  margin-top: 14px;
}

#settings-view .toggle {
  margin-left: 0;
}

/* The toast sits above the home indicator. */
.toast {
  bottom: calc(20px + env(safe-area-inset-bottom));
}
