/* ==========================================================================
   Names of Allah PWA — Refined finish (refine.css)
   Loaded last. Two jobs:
   1. Define the design values iterations.css expects (rounding, teal, gold).
      The iterations page set these in an inline <style>; the main page never did,
      so the live homepage rendered with square corners and grey labels.
   2. A calmer, roomier homepage: more space, softer borders, fewer marks,
      and the layout switcher tucked into a header menu.
   ========================================================================== */

/* ---------- 1. Design values ---------- */
:root {
  --color-primary: #1a5f4a;
  --color-primary-rgb: 26, 95, 74;
  /* Darker than the iterations gold (#c9a227) so small labels pass 4.5:1 on white */
  --color-accent: #8f6f1c;
  --border-medium: #e2dccf;
  --bg-secondary: var(--bg-subtle);
  --text-muted: #6f6f6f;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --space-sm: 0.5rem;
  --space-xl: 2rem;
  /* The studio bar is gone, so the header pins to the top */
  --studio-bar-h: 0px;
}

[data-theme="dark"] {
  --color-primary: #5cb89a;
  --color-primary-rgb: 92, 184, 154;
  --color-accent: #d4b44a;
  --border-medium: #2e3448;
  --text-muted: #9090a0;
  --bg-page: #0f111a;
  --bg-primary: #0f111a;
  --bg-secondary: #171a26;
  --bg-subtle: #171a26;
  --bg-card: #1d2130;
  --text-primary: #f1ede4;
  --text-secondary: #b4b8c8;
  --border-light: #2a2f42;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary: #5cb89a;
    --color-primary-rgb: 92, 184, 154;
    --color-accent: #d4b44a;
    --border-medium: #2e3448;
    --text-muted: #9090a0;
    --bg-page: #0f111a;
    --bg-primary: #0f111a;
    --bg-secondary: #171a26;
    --bg-subtle: #171a26;
    --bg-card: #1d2130;
    --text-primary: #f1ede4;
    --text-secondary: #b4b8c8;
    --border-light: #2a2f42;
  }
}

/* Dark mode: keep the hero a deep green (carried over from the iterations page) */
[data-theme="dark"] .v1-hero,
[data-theme="dark"] .bento-hero-name {
  background: linear-gradient(145deg, #0b2920 0%, #134636 60%, #1c5f4a 100%);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .v1-hero,
  :root:not([data-theme="light"]) .bento-hero-name {
    background: linear-gradient(145deg, #0b2920 0%, #134636 60%, #1c5f4a 100%);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- 2. Remove the studio bar ---------- */
.iter-studio-bar { display: none !important; }

/* ---------- 3. Header: quieter, with a balanced action group ---------- */
.header-content { padding: var(--space-4) 0; }
.header-side {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 5.75rem; /* two icon buttons, so the title stays centred */
}
.header-side-end { justify-content: flex-end; }

.demo-banner {
  background: transparent;
  border-top: 1px solid var(--border-light);
  padding: 6px 16px;
}
[data-theme="dark"] .demo-banner { background: transparent; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .demo-banner { background: transparent; }
}

@media (max-width: 480px) {
  /* Two 42px buttons a side leaves 158px for the 152px Arabic title */
  .header-content { gap: var(--space-2); }
  .header-side { width: 5.25rem; gap: 0; }
  .header-side .btn-icon { width: 2.625rem; height: 2.625rem; }
}

/* ---------- 4. Layout menu (replaces the tab bar) ---------- */
/* Anchored to the right action group, so it lines up with the page gutter */
.header-side-end { position: relative; }

.layout-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: calc(var(--z-sticky, 1100) + 20);
  width: min(320px, calc(100vw - 48px));
  padding: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(16, 24, 22, 0.16);
  text-align: left;
  animation: layoutMenuIn 160ms ease-out;
}
.layout-menu[hidden] { display: none; }

@keyframes layoutMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.layout-menu-title {
  margin: 4px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.layout-option {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-primary);
  font-family: var(--font-ui);
  text-align: left;
  cursor: pointer;
}
.layout-option:hover,
.layout-option:focus-visible { background: var(--bg-subtle); outline: none; }
.layout-option:focus-visible { box-shadow: inset 0 0 0 2px var(--color-primary); }

.layout-option-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.layout-option-name { font-size: 14px; font-weight: 600; }
.layout-option-desc { font-size: 12.5px; line-height: 1.4; color: var(--text-tertiary); }

.layout-option-check {
  flex-shrink: 0;
  color: var(--color-primary);
  visibility: hidden;
}
.layout-option[aria-checked="true"] .layout-option-name { color: var(--color-primary); }
.layout-option[aria-checked="true"] .layout-option-check { visibility: visible; }

/* ---------- 5. Roomier, calmer homepage ---------- */
/* The page already has 48px top padding; adding more left a blank band */
#welcomeView.iter-welcome-view {
  padding-top: 0;
  padding-bottom: 56px;
}

/* Hero */
.v1-hero {
  padding: 36px 36px 30px;
  margin-bottom: 20px;
  border: none;
  box-shadow: 0 10px 30px rgba(16, 42, 40, 0.14);
}
.v1-hero-top { margin-bottom: 22px; }
.v1-hero-eyebrow { margin-bottom: 8px; }
.v1-hero-heading {
  font-size: clamp(1.4rem, 2.6vw, 1.85rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}
.v1-search-box { margin-bottom: 18px; }
.v1-quick-pills { gap: 8px; }
.v1-quick-pill { padding: 6px 12px; font-size: 12px; }

/* Hadith line */
.compact-hadith-bar {
  border-color: var(--border-light);
  border-left-width: 1px;
  padding: 14px 18px;
  margin-bottom: 40px;
}

/* Three summary cards */
.v1-continue-grid {
  gap: 16px;
  margin-bottom: 48px;
}
.v1-spotlight-card {
  padding: 22px 24px 18px;
  gap: 14px;
  border-color: var(--border-light);
  box-shadow: none;
}
.v1-spotlight-card.primary-spotlight { border-left: 3px solid var(--color-primary); }
.v1-card-kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; }
.v1-spotlight-translit { font-size: 19px; font-weight: 600; margin-bottom: 4px; }
.v1-spotlight-invoke { font-size: 13px; line-height: 1.55; }
.v1-spotlight-arabic { font-size: 42px; }
.v1-spotlight-footer { padding-top: 12px; }
.v1-spotlight-cta { font-weight: 600; font-size: 12.5px; }

/* Section headings */
.v1-shelf-section { margin-bottom: 48px; }
.shelf-header { margin-bottom: 16px; }
.shelf-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.shelf-subtitle { font-size: 12.5px; color: var(--text-tertiary); }

/* Situation cards: fill the row instead of leaving an empty column */
.v1-situation-scroller {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.v1-sit-card {
  padding: 18px 20px 16px;
  gap: 16px;
  box-shadow: none;
}
.v1-sit-card:hover,
.v1-mini-name-card:hover { transform: none; box-shadow: 0 6px 18px rgba(16, 42, 40, 0.08); }
.v1-sit-title { font-size: 14.5px; font-weight: 500; line-height: 1.45; }
.v1-sit-names-preview { padding-top: 12px; border-top-style: solid; }

/* Names + videos */
.v1-bottom-split { gap: 40px; }
.v1-mini-names-grid { gap: 12px; }
.v1-mini-name-card { padding: 14px 16px; }
.v1-mini-diamond {
  border: none;
  background: var(--bg-subtle);
  border-radius: 50%;
  color: var(--text-tertiary);
  font-weight: 600;
}
.v1-mini-translit { font-weight: 600; font-size: 14px; }
.v1-mini-arabic { font-size: 24px; }
.v1-video-stack { gap: 12px; }

/* Phones: keep the room, trim the padding */
@media (max-width: 640px) {
  main.main { padding-top: 24px; }
  .v1-hero { padding: 26px 20px 22px; }
  .compact-hadith-bar { margin-bottom: 28px; }
  .v1-continue-grid,
  .v1-shelf-section { margin-bottom: 36px; }
  .v1-spotlight-card { padding: 18px 18px 14px; }
  .v1-bottom-split { gap: 36px; }
}

/* ---------- 6. Subtle polish ---------- */

/* Hero: a faint eight-point star lattice behind the calligraphy, fading out to the left */
.v1-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23C9A961' stroke-width='1'%3E%3Crect x='16' y='16' width='24' height='24'/%3E%3Crect x='16' y='16' width='24' height='24' transform='rotate(45 28 28)'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.09;
  -webkit-mask-image: linear-gradient(to left, #000 0%, transparent 65%);
  mask-image: linear-gradient(to left, #000 0%, transparent 65%);
  pointer-events: none;
}
.v1-hero-top { position: relative; z-index: 1; }

/* Hero pills: one height, whether or not they carry Arabic */
.v1-quick-pill {
  height: 34px;
  padding: 0 13px;
  line-height: 1;
}
.v1-quick-pill-ar { line-height: 1; }

/* Hadith: a quiet gold underline instead of a shaded box */
.compact-hadith-bar .hadith-key,
[data-theme="dark"] .compact-hadith-bar .hadith-key {
  background: none;
  padding: 0;
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .compact-hadith-bar .hadith-key { background: none; }
}

/* Name in focus: a soft teal wash replaces the thick side bar */
.v1-spotlight-card.primary-spotlight {
  border-left: 1px solid var(--border-light);
  background:
    linear-gradient(135deg, rgba(var(--color-primary-rgb), 0.07) 0%, transparent 55%),
    var(--bg-card);
}

/* Card labels sit on one line across all three cards */
.v1-card-kicker { min-height: 24px; }

/* Situation cards: give the Arabic room to breathe */
.v1-sit-ar-chips { gap: 6px; }
.v1-sit-ar-chip {
  padding: 3px 11px 4px;
  font-size: 15px;
  line-height: 1.5;
}

/* Name numbers sit in an eight-point star */
.v1-mini-diamond {
  width: 34px;
  height: 34px;
  border-radius: 0;
  clip-path: polygon(50% 0%, 64.6% 14.6%, 85.4% 14.6%, 85.4% 35.4%, 100% 50%, 85.4% 64.6%, 85.4% 85.4%, 64.6% 85.4%, 50% 100%, 35.4% 85.4%, 14.6% 85.4%, 14.6% 64.6%, 0% 50%, 14.6% 35.4%, 14.6% 14.6%, 35.4% 14.6%);
  background: rgba(var(--color-primary-rgb), 0.09);
  color: var(--color-primary);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

/* Keyboard users see where they are */
.v1-sit-card:focus-visible,
.v1-mini-name-card:focus-visible,
.v1-video-card:focus-visible,
.v1-quick-pill:focus-visible,
.v1-spotlight-cta:focus-visible,
.shelf-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}
.v1-hero .v1-quick-pill:focus-visible { outline-color: var(--gold-300, #D9C291); }

@media (prefers-reduced-motion: reduce) {
  .iter-pane,
  .layout-menu { animation: none; }
}

/* ---------- 7. Browse view: filters + compact cards ---------- */
.browse-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}
.browse-filter {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.browse-filter:hover { border-color: var(--color-primary); color: var(--text-primary); }
.browse-filter:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.browse-filter-count {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.browse-filter.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.browse-filter.active .browse-filter-count { color: rgba(255, 255, 255, 0.78); }
[data-theme="dark"] .browse-filter.active { color: #0f111a; }
[data-theme="dark"] .browse-filter.active .browse-filter-count { color: rgba(15, 17, 26, 0.7); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .browse-filter.active { color: #0f111a; }
  :root:not([data-theme="light"]) .browse-filter.active .browse-filter-count { color: rgba(15, 17, 26, 0.7); }
}

#searchCount { padding-bottom: 4px; }

/* Compact grid: Arabic, name and meaning only */
#namesList .names-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  padding: 12px 0 32px;
}
#namesList .name-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 44px 16px 20px;
  border-radius: var(--radius-md);
  border-color: var(--border-light);
}
#namesList .name-card:hover {
  transform: none;
  border-color: var(--color-primary);
  box-shadow: 0 6px 18px rgba(16, 42, 40, 0.08);
}
#namesList .name-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}
#namesList .name-number { top: 14px; left: 14px; }
#namesList .video-badge { top: 12px; left: auto; right: 14px; }
#namesList .card-arabic {
  font-size: clamp(1.9rem, 3.2vw, 2.3rem);
  font-weight: 400;
  margin: 0 0 10px;
  color: var(--color-primary);
}
#namesList .card-meta { margin: 0; }
#namesList .card-transliteration { font-size: 15.5px; font-weight: 600; margin-bottom: 2px; }
#namesList .card-meaning { font-size: 13px; line-height: 1.45; }

@media (max-width: 480px) {
  #namesList .names-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  #namesList .name-card { padding: 40px 10px 16px; }
  .browse-filter { padding: 0 13px; font-size: 13px; }
}

/* ---------- 8. Fewer elements ---------- */

/* Back to Home: a plain text link, not a boxed bar.
   IDs beat the page's inline <style>, which loads after this file. */
#subviewBackBar {
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 4px;
}
#subviewBackBar .subview-back-btn {
  min-height: 44px;
  padding: 0;
  border: none;
  background: none;
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 500;
}
#subviewBackBar .subview-back-btn:hover { background: none; text-decoration: underline; text-underline-offset: 4px; }
#subviewBackBar .subview-back-btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 4px; }
.browse-header { padding-top: var(--space-2); }

/* Card footers that lost their left-hand note keep the link on the right */
.v1-spotlight-cta { margin-left: auto; }

/* Situations source note: one quiet line instead of a second warning box */
.situations-draft-banner {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* Sub-pages: "← Home" sits as a small line directly above each title,
   with the same 8px gap on every page */
#subviewBackBar { margin-bottom: 8px; }
#subviewBackBar .subview-back-btn { min-height: 32px; }
/* Memorise is a padded card, so it keeps its own inner spacing */
#mainContent .view:not(#welcomeView):not(#memorizeView) > :first-child,
#mainContent .view:not(#welcomeView):not(#memorizeView) > :first-child > :first-child,
.progress-view-inner > :first-child > h2,
.favorites-header h2,
.browse-header h2 {
  margin-top: 0;
  padding-top: 0;
}

/* ---------- 9. Source marks: small coloured icons ---------- */
.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.mark svg { width: 12px; height: 12px; }
.mark-quran  { background: rgba(var(--color-primary-rgb), 0.12); color: var(--color-primary); }
.mark-sunnah { background: rgba(201, 162, 39, 0.16); color: var(--color-accent); }
.mark-video  { background: var(--bg-subtle); color: var(--text-tertiary); }
.mark-saved  { background: rgba(201, 162, 39, 0.16); color: var(--color-accent); }

#namesList .card-marks {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
}
#namesList .name-card { padding-top: 46px; }

/* On filter buttons the icon leads the label */
.browse-filter .mark { width: 20px; height: 20px; margin-left: -6px; }
.browse-filter .mark svg { width: 11px; height: 11px; }
.browse-filter.active .mark { background: rgba(255, 255, 255, 0.2); color: inherit; }
