/* ================================
   Home Hub — Full Stylesheet
   ================================ */

:root {
  --bg: #f2f3f4;
  --ink: #111318;
  --muted: #5a6472;
  --card: #ffffff;
  --line: #d8dde3;
  --accent: #ff7828; /* Dynamic Dexter orange */
  --accent-dark: #0e0f12;
  --btn-bg: #0f172a;
  --btn-fg: #ffffff;
  --btn-hover: #ff7828;
  --focus: #ff7828;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
html {
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    16px/1.5 Arial,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
a:hover {
  text-decoration: underline;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
strong {
  font-weight: 700;
}

/* ========== Header ========== */
.hub-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: "left center right";
  align-items: center;
  padding: 14px 18px;
  background: #f2f3f4;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.header-left {
  grid-area: left;
  justify-self: start;
}
.header-center {
  grid-area: center;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-right {
  grid-area: right;
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.hub-header h1 {
  margin: 0;
  font-size: 20px;
}

.header-weather {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  backdrop-filter: blur(4px);
  min-height: 38px;
}
.header-weather-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: 0 0 auto;
}
.header-weather-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}
.header-weather-meta {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.1;
}
.header-weather-temp {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}
.header-weather-desc {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ========== Left menu ========== */
.menu-btn {
  position: fixed;
  top: calc(0.75em + env(safe-area-inset-top));
  left: calc(0.75em + env(safe-area-inset-left));
  z-index: 1200;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.menu-btn:hover {
  background: var(--btn-hover);
}

.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 1250;
}

.menu-panel {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: min(280px, calc(100vw - 3.25rem));
  background: var(--bg);
  border-right: 2px solid var(--line);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
  z-index: 1300;
  padding: calc(14px + env(safe-area-inset-top)) 14px
    calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-105%);
  transition: transform 0.18s ease;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}
.menu-panel.open {
  transform: translateX(0);
}
.menu-title {
  margin: 2px 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-title-img {
  display: block;
  width: min(180px, 100%);
  height: auto;
}
.menu-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 8px 0;
}

.menu-search {
  margin-top: 2px;
}

.menu-search-container {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  padding: 0 12px;
  box-shadow: none;
}

.menu-search-input {
  padding: 10px 0;
  font-size: 0.95rem;
}

.menu-spacer {
  flex: 1;
}

.menu-items {
  display: grid;
  gap: 10px;
}

.menu-bottom-items {
  margin-top: auto;
}

.menu-link {
  width: 100%;
  min-height: 44px;
  border: 1px solid #d8dde3;
  border-radius: 10px;
  background: var(--btn-bg);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.72rem 1rem;
  cursor: pointer;
  text-decoration: none;
}

.menu-link:hover {
  background: var(--btn-hover);
  text-decoration: none;
}

.menu-link-wrap {
  white-space: normal;
  text-align: center;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--line);
}

body.side-menu-open {
  overflow: hidden;
}

/* ========== Main layout ========== */
main {
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 16px;
  width: 100%;
  flex: 1 0 auto;
}
.actions {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
}

/* ========== Footer ========== */
.hub-footer {
  background: #0f172a;
  color: #ffffff;
  text-align: center;
  padding: 16px;
  margin-top: auto;
}
.hub-footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease,
    background 0.16s ease;
  z-index: 1400;
}
.back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--btn-hover);
}

@media (max-width: 720px) {
  .back-to-top {
    right: 14px;
    bottom: 14px;
  }
}

/* ========== Search bar ========== */
.search-container {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0 16px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.header-search-container {
  width: 100%;
  min-height: 52px;
}
.search-container:focus-within {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(255, 120, 40, 0.15);
}
.search-icon {
  width: 20px;
  height: 20px;
  color: var(--muted);
  flex: 0 0 auto;
  margin-right: 12px;
}
.search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 16px;
  padding: 14px 0;
  color: var(--ink);
  outline: none;
}
.search-input::placeholder {
  color: var(--muted);
  opacity: 1;
}
.search-clear {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
  margin-left: 8px;
  transition: background 0.15s ease;
}
.search-clear:hover {
  background: var(--bg);
  color: var(--ink);
}
.app-search-empty {
  margin: 0 0 18px;
}
.card-match {
  background: color-mix(in srgb, var(--accent) 20%, #fff);
  color: inherit;
  border-radius: 4px;
  padding: 0 0.12em;
}

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

/* ========== Today panel ========== */
.today {
  margin: 0 0 12px;
}
.today-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.today-left-section {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.today-left {
  min-width: 0;
}
.today-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  align-self: stretch;
  padding: 0 18px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  max-width: 420px;
  width: 100%;
  justify-self: center;
}
.today-right {
  display: grid;
  grid-template-columns: 1fr 1px auto;
  align-items: center;
  column-gap: 12px;
  justify-self: stretch;
  width: 100%;
}
.today-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  justify-self: end;
}
.today-right-divider {
  width: 1px;
  height: 74px;
  background: var(--line);
}
.today-todo-link {
  min-height: 40px;
  padding: 7px 16px;
  border-radius: 10px;
  white-space: nowrap;
  justify-self: center;
}
.today-avatar {
  width: 100px;
  height: 100px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.today-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.today-greeting {
  font-size: 14px;
  color: var(--ink);
}
.today-date {
  font-size: 16px;
  font-weight: 650;
}
.today-time {
  font-size: 26px;
  font-weight: 750;
  line-height: 1.1;
}
.today-weekday {
  font-size: 13px;
}

/* ========== Word of the Day ========== */
.word-of-day {
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  padding: 12px 14px;
  text-align: center;
}
.word-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.word-label::after {
  content: ":";
}
.word-of-day-word {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}
.word-of-day-definition {
  font-size: 12px;
  color: var(--ink);
  line-height: 1.3;
  margin: 0;
  max-width: 220px;
}

/* ========== Buttons ========== */
.btn {
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: none;
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 0.06s ease,
    opacity 0.15s ease;
}
.btn:hover {
  background: var(--btn-hover);
  transform: translateY(-1px);
  text-decoration: none;
}
.btn:focus {
  text-decoration: none;
}
.btn:active {
  text-decoration: none;
}
.btn:active {
  transform: none;
}
.btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn.secondary {
  background: var(--btn-bg);
}
.btn.secondary:hover {
  background: var(--btn-hover);
}

/* ========== Section controls ========== */
.section-controls {
  display: flex;
  gap: 10px;
  margin: 0 0 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.section-control-btn {
  padding: 8px 12px;
  font-size: 14px;
}

/* ========== Divider ========== */
.section-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0 18px;
}

.google-search {
  margin: 0 0 2px;
}

.google-search-form {
  width: 100%;
}

.google-search-container {
  width: min(760px, 100%);
  min-height: 52px;
  margin: 0 auto;
}

.google-search-input {
  padding: 12px 0;
}

.google-search-submit {
  border: 1px solid var(--line);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  min-height: 34px;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: background 0.16s ease;
  margin-left: 10px;
}

.google-search-submit:hover {
  background: var(--btn-hover);
}

/* ========== Cards grid ========== */
.services-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.service-section {
  margin: 0;
}
.section-title {
  width: 100%;
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  backdrop-filter: blur(4px);
  cursor: pointer;
  text-align: left;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-weight: inherit;
  font-size: 13px;
  letter-spacing: inherit;
}
.section-title:hover {
  background: var(--card);
  border-color: #c7cdd6;
}
.section-title:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.section-title::after {
  content: "▼";
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s ease;
  flex: 0 0 auto;
}
.section-title[aria-expanded="false"]::after {
  transform: rotate(-90deg);
}
.section-title[aria-expanded="false"] ~ .grid {
  display: none;
}
.section-title-icon {
  margin: 0;
  font-size: 14px;
  vertical-align: -1px;
  flex: 0 0 auto;
}
.section-title-text {
  flex: 1;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-rows: 1fr;
  gap: 16px;
}

/* Two-up tiles inside each category */
.services-grid .grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 132px;
  height: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    transform 0.12s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px
    color-mix(in srgb, var(--tile, #2b3039) 38%, transparent);
  border-color: #c7cdd6;
  text-decoration: none;
}
.card:focus-visible {
  transform: translateY(-2px);
  box-shadow:
    0 12px 24px color-mix(in srgb, var(--tile, #2b3039) 38%, transparent),
    0 0 0 2px rgba(255, 120, 40, 0.25);
  border-color: #ff7828;
  text-decoration: none;
}
.thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--tile, #2b3039);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease;
}
.card:hover .thumb,
.card:focus-visible .thumb {
  transform: translateY(-1px) scale(1.02);
}
.emoji {
  font-size: 28px;
}
.thumb-logo {
  width: var(--logo-size, 30px);
  height: var(--logo-size, 30px);
  object-fit: contain;
  display: block;
  filter: brightness(0) invert(1);
}
.card-name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  max-width: 100%;
  min-height: 2.5em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-wrap: balance;
}

/* ========== Auth pages (login/register) ========== */
main.auth {
  max-width: 520px;
  margin: 40px auto;
  padding: 0 16px;
}

/* Home Hub login scene to match Home Library/Movie Tracker */
.homehub-login-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.homehub-login-page .homehub-login-header {
  padding: 10px 18px;
}

.homehub-login-page .header-center {
  width: min(640px, 78vw);
  justify-content: center;
}

.homehub-login-page .hub-banner {
  width: 100%;
  height: 96px;
  object-fit: contain;
  object-position: center;
}

.homehub-login-page main.auth.homehub-login-main {
  position: relative;
  isolation: isolate;
  width: min(1240px, 92%);
  max-width: none;
  margin: 0 auto;
  padding: 28px 0 44px;
  display: grid;
  place-items: center;
}

.homehub-login-page.is-login-scene main.auth.homehub-login-main::before {
  content: "";
  position: fixed;
  inset: 70px -16vw -8vh -16vw;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(
      40% 30% at 18% 22%,
      rgba(255, 120, 40, 0.2),
      transparent 70%
    ),
    radial-gradient(
      36% 26% at 78% 28%,
      rgba(15, 23, 42, 0.12),
      transparent 70%
    ),
    radial-gradient(
      45% 36% at 52% 74%,
      rgba(255, 120, 40, 0.13),
      transparent 72%
    );
  filter: blur(26px);
}

.homehub-login-card {
  position: relative;
  overflow: hidden;
  width: min(640px, 100%);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.09);
  padding: 28px;
}

.homehub-login-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background: repeating-linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.26) 0px,
    rgba(15, 23, 42, 0.26) 1px,
    transparent 1px,
    transparent 3px
  );
}

.homehub-login-page .eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.homehub-login-title {
  display: inline-block;
  margin: 0;
  font-size: clamp(2rem, 5vw, 2.8rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
}

.homehub-login-page .form {
  margin-top: 12px;
  display: grid;
  gap: 14px;
}

.homehub-login-page .form label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

.homehub-login-page .form input {
  padding: 13px 14px;
  border-radius: 10px;
}

.homehub-login-page .login-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 2px;
}

.homehub-login-page .login-actions .btn {
  min-width: 122px;
}

.homehub-login-page .hint {
  margin-top: 14px;
}

@media (max-width: 640px) {
  .homehub-login-page .hub-banner {
    height: 72px;
  }

  .homehub-login-card {
    padding: 22px;
  }
}

main.auth h2 {
  margin: 0 0 12px;
}
.page-title {
  display: flex;
  justify-content: center;
}
.page-title-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 520px;
  height: auto;
}
.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}
.form select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}
.form input[type="checkbox"] {
  padding: 0;
  border-radius: 6px;
  width: 18px;
  height: 18px;
}
.service-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.service-option {
  display: flex;
  align-items: center;
  gap: 10px;
}
.divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}
.admin-title {
  margin: 0 0 12px;
  font-size: 16px;
}
.hint {
  color: var(--muted);
  margin-top: 6px;
}

/* ========== Utilities ========== */
.muted {
  color: var(--muted);
}
.center {
  text-align: center;
}
.right {
  text-align: right;
}

/* ========== Responsive tweaks ========== */
@media (max-width: 720px) {
  .hub-header {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "center center"
      "left right";
    grid-template-rows: auto auto;
  }
  .header-center {
    order: -1;
    width: 100%;
    flex-direction: column;
    gap: 12px;
  }
  .header-right {
    align-items: flex-end;
  }
  main {
    padding: 0 12px;
  }
  .section-title {
    top: 72px;
  }
  .services-grid {
    grid-template-columns: 1fr;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
  .services-grid .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .card {
    min-height: 124px;
  }
  .today-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .today-center {
    border-left: none;
    border-right: none;
    padding: 6px 0 0;
    max-width: none;
  }
  .today-right {
    grid-template-columns: 1fr;
    row-gap: 8px;
    justify-items: center;
  }
  .today-right-divider {
    display: none;
  }
  .today-clock {
    align-items: center;
    justify-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .thumb {
    transition: none;
  }
  .card:hover,
  .card:focus-visible,
  .card:hover .thumb,
  .card:focus-visible .thumb {
    transform: none;
  }
}

.hub-banner {
  height: 70px; /* Main control for logo size */
  width: auto; /* Keeps proportions correct */
  max-width: 100%; /* Prevents overflow on small screens */
  display: block;
}
