/* ============================================================
   ESTIA — Netflix風モバイルファーストUI
   ============================================================ */

/* ── リセット & ベース ─────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:          #141414;
  --bg-card:     #1f1f1f;
  --bg-card2:    #2a2a2a;
  --accent:      #e50914;
  --accent-hover:#f40612;
  --text:        #ffffff;
  --text-muted:  #b3b3b3;
  --text-dim:    #737373;
  --border:      #333333;
  --radius:      6px;
  --radius-lg:   12px;
  --header-h:    56px;
  --bottom-nav-h:60px;
  --font:        'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

/* ── ログイン画面 ─────────────────────────────────────── */
.login-body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: #000;
}

.login-bg {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(
      160deg,
      rgba(180, 10, 20, 0.15) 0%,
      rgba(0,0,0,0) 50%,
      rgba(20, 20, 20, 0.8) 100%
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(255,255,255,0.01) 3px,
      rgba(255,255,255,0.01) 4px
    );
  z-index: 0;
}

.login-bg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1;
}

.login-header {
  position: relative;
  z-index: 10;
  padding: 20px 24px;
}

.brand-logo {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--accent);
}

.login-main {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: var(--radius-lg);
  padding: 40px 32px 48px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 28px;
  color: var(--text);
}

.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(229, 9, 20, 0.15);
  border: 1px solid rgba(229, 9, 20, 0.4);
  color: #ff6b6b;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.4;
}

.btn-google-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  background: #fff;
  color: #3c4043;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  text-decoration: none;
}

.btn-google-login:hover,
.btn-google-login:active {
  background: #f1f3f4;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.google-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.login-note {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 20px;
  line-height: 1.4;
}

/* ── アプリ共通ヘッダー ──────────────────────────────── */
.app-body {
  padding-top: var(--header-h);
  padding-bottom: var(--bottom-nav-h);
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  z-index: 100;
  background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
  transition: background 0.3s;
}

.app-header.scrolled {
  background: rgba(20, 20, 20, 0.98);
}

.app-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  height: 100%;
}

.app-header .brand-logo {
  flex-shrink: 0;
  text-decoration: none;
  line-height: 0;
}

.brand-logo-img {
  height: 28px;
  width: auto;
  display: block;
  object-fit: contain;
}

.app-nav {
  display: flex;
  gap: 12px;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.app-nav::-webkit-scrollbar { display: none; }

.nav-link {
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s;
}

.nav-link.active,
.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  border-bottom-color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  border-radius: 50%;
  transition: background 0.15s;
  padding: 0;
  text-decoration: none;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:active {
  background: rgba(255,255,255,0.1);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn.spinning svg {
  animation: spin 0.8s linear infinite;
}

.logout-link {
  font-size: 13px;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
}

.logout-link:hover {
  background: var(--bg-card2);
  color: var(--text);
}

/* ── メインコンテンツ ─────────────────────────────────── */
.app-main {
  min-height: calc(100dvh - var(--header-h) - var(--bottom-nav-h));
}

/* ── ヒーローバナー ──────────────────────────────────── */
/* ── 本日出勤スクロール ──────────────────────────────── */
.cast-scroll-section {
  padding: 12px 0 6px;
}

.cast-scroll-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: var(--accent);
  padding: 0 16px 8px;
}

.cast-scroll-row {
  overflow: hidden;
  margin-bottom: 6px;
  /* 両端フェードアウト */
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 10%, #000 90%, transparent 100%);
  mask-image:         linear-gradient(to right, transparent 0%, #000 10%, #000 90%, transparent 100%);
}

.cast-scroll-track {
  display: flex;
  gap: 10px;
  width: max-content;
  will-change: transform;
  padding: 4px 0 6px; /* shadow が切れないよう余白 */
}

.track-forward {
  animation: cast-scroll-forward linear infinite;
}

.track-reverse {
  animation: cast-scroll-reverse linear infinite;
}

.cast-scroll-track:hover,
.cast-scroll-track:focus-within {
  animation-play-state: paused;
}

@keyframes cast-scroll-forward {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

@keyframes cast-scroll-reverse {
  0%   { transform: translateX(-50%); }
  100% { transform: translateX(0); }
}

/* ── ポートレートカード ───────────────────────────────── */
.cast-chip {
  position: relative;
  flex-shrink: 0;
  width: 85px;
  height: 115px;
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  display: block;
  background: var(--bg-card2);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.2s;
}

.cast-chip:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.cast-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.cast-chip-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 800;
  color: var(--text-dim);
  background: linear-gradient(160deg, #1f1f1f 0%, #2c2c2c 100%);
}

/* グラデーションオーバーレイ＋テキスト */
.cast-chip-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    transparent 40%,
    rgba(0,0,0,0.25) 65%,
    rgba(0,0,0,0.82) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 8px 7px 7px;
  gap: 2px;
}

.cast-chip-name {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  line-height: 1.3;
}

.cast-chip-time {
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.3px;
}

/* ── キラキラ(glitter + shimmer) ───────────────────── */

/* グリッター: 小さな輝く点をスクリーンブレンドで重ねてパルス */
.cast-chip::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.95) 0.6px, transparent 1.8px),
    radial-gradient(circle, rgba(255,220,100,0.85)  0.5px, transparent 1.4px),
    radial-gradient(circle, rgba(200,230,255,0.9)   0.5px, transparent 1.6px),
    radial-gradient(circle, rgba(255,255,255,0.8)   0.4px, transparent 1.2px);
  background-size: 24px 24px, 36px 36px, 48px 48px, 60px 60px;
  background-position: 4px 7px, 14px 19px, 6px 32px, 21px 11px;
  animation: chip-twinkle var(--shimmer-cycle, 2s) ease-in-out infinite alternate;
  animation-delay: var(--shimmer-delay, 0s);
}

/* シマー: 斜めの光の帯がカードを横切る（transform でGPU駆動） */
.cast-chip::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    112deg,
    transparent 30%,
    rgba(255,255,255,0.20) 50%,
    transparent 70%
  );
  transform: translateX(-200%);
  animation: chip-sweep calc(var(--shimmer-cycle, 2s) * 2.2) ease-in-out infinite;
  animation-delay: var(--shimmer-delay, 0s);
}

@keyframes chip-twinkle {
  0%   { opacity: 0; }
  45%  { opacity: 1; }
  100% { opacity: 0.15; }
}

@keyframes chip-sweep {
  0%   { transform: translateX(-200%); }
  50%  { transform: translateX(200%); }
  100% { transform: translateX(200%); }
}


/* ── ボタン ──────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--accent-hover);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: rgba(109,109,110,0.7);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover,
.btn-secondary:active {
  background: rgba(109,109,110,0.9);
}

/* ── セクション ──────────────────────────────────────── */
.section {
  padding: 16px 0 24px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  padding: 0 16px 12px;
  color: var(--text);
}

/* ── サイトグリッド ──────────────────────────────────── */
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  padding: 0 16px;
}

.site-card {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.site-card:has(.site-card-thumb:hover),
.site-card:has(.site-card-thumb:active) {
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.site-card-thumb {
  display: block;
  text-decoration: none;
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg-card2);
  overflow: hidden;
}

.site-card-thumb:has(img) {
  background: #fff;
}

.site-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.site-card-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-dim);
  background: linear-gradient(135deg, #1f1f1f, #2a2a2a);
}

.site-card-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.badge-active {
  background: rgba(70,211,105,0.9);
  color: #000;
}

.badge-inactive {
  background: rgba(100,100,100,0.9);
  color: #fff;
}

.site-card-info {
  padding: 8px 10px 10px;
}

.site-card-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-card-url {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── エンプティステート ──────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-icon {
  width: 56px;
  height: 56px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.empty-icon svg {
  width: 100%;
  height: 100%;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.empty-desc {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 24px;
  line-height: 1.5;
  max-width: 280px;
}

/* ── ボトムナビ ──────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: rgba(20, 20, 20, 0.97);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
  padding: 8px 4px;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
}

.bottom-nav-item.active,
.bottom-nav-item:active {
  color: var(--text);
}

/* ── セットアップ画面 ─────────────────────────────────── */
.setup-card {
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
}

.setup-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 24px;
}

.setup-msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 8px;
  line-height: 1.4;
}

.setup-msg svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.setup-msg-ok {
  background: rgba(70,211,105,0.12);
  border: 1px solid rgba(70,211,105,0.3);
  color: #46d369;
}

.setup-msg-err {
  background: rgba(229,9,20,0.12);
  border: 1px solid rgba(229,9,20,0.3);
  color: #ff6b6b;
}

/* ── タブレット以上は少し調整 ─────────────────────────── */
@media (min-width: 768px) {
  .site-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
  }

  .brand-logo-img { height: 32px; }
}
