/* ============================================================
   CalSync - Apple.com-grade Design System
   "余白は語る。写真で魅せる。テキストは絞る。"
   ============================================================ */

/* --- Web Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+JP:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Colors - Apple monochrome palette */
  --color-bg: #fbfbfd;
  --color-surface: #ffffff;
  --color-text: #1d1d1f;
  --color-text-secondary: #6e6e73;
  --color-text-tertiary: #86868b;
  --color-border: #d2d2d7;
  --color-border-light: #e8e8ed;
  --color-accent: #0071e3;
  --color-accent-hover: #0077ED;
  --color-accent-light: #e1f0ff;

  /* Typography */
  --font-sans: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  --font-display: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing - 8px grid */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* Shadows - more subtle, more layers */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.1), 0 4px 20px rgba(0,0,0,0.05);
  --shadow-2xl: 0 30px 80px rgba(0,0,0,0.12), 0 8px 30px rgba(0,0,0,0.06);
  --shadow-hero: 0 40px 120px rgba(0,0,0,0.15), 0 10px 40px rgba(0,0,0,0.08);

  /* Transitions */
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.3s;
  --duration-slow: 0.6s;
  --duration-slower: 1s;
}

/* --- Reset & Foundation --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'kern' 1, 'liga' 1;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  letter-spacing: -0.01em;
  overflow-x: hidden;
}

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

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--duration) var(--ease-out);
}

a:hover {
  color: var(--color-accent-hover);
}

/* --- Apple-style Typography System --- */
.text-display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.05;
  color: var(--color-text);
}

.text-headline {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.1;
  color: var(--color-text);
}

.text-title {
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--color-text);
}

.text-body {
  font-weight: 400;
  line-height: 1.65;
  color: var(--color-text-secondary);
}

.text-caption {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--color-text-tertiary);
  letter-spacing: 0;
}

.text-eyebrow {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--color-accent);
}

/* Gradient text - Apple-style iridescent */
.gradient-text {
  background: linear-gradient(135deg, #0071e3 0%, #5856d6 45%, #bf5af2 70%, #ff375f 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-text-subtle {
  background: linear-gradient(135deg, #0071e3 0%, #5856d6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Apple Frosted Glass Navbar --- */
.apple-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(251, 251, 253, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid rgba(0,0,0,0.08);
  transition: all var(--duration) var(--ease-out);
}

.apple-nav a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0;
  transition: color var(--duration) var(--ease-out);
}

.apple-nav a:hover {
  color: var(--color-text);
}

/* Ensure buttons in nav keep their own colors */
.apple-nav .btn-primary {
  color: #fff !important;
  background: var(--color-accent);
}

.apple-nav .btn-primary:hover {
  color: #fff !important;
  background: var(--color-accent-hover);
}

/* --- Buttons (Apple-style pill) --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.75rem 1.75rem;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  transform: scale(1.02);
  box-shadow: 0 4px 16px rgba(0,113,227,0.25);
  color: #fff !important;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.75rem 1.75rem;
  background: transparent;
  color: var(--color-accent);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.btn-glass {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.5rem;
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--color-text);
  border: 0.5px solid rgba(0,0,0,0.1);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  text-decoration: none;
}

.btn-glass:hover {
  background: rgba(255,255,255,0.92);
  box-shadow: var(--shadow-md);
  color: var(--color-text);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.75rem;
  background: transparent;
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  text-decoration: none;
}

.btn-outline:hover {
  border-color: var(--color-text);
  color: var(--color-text);
}

/* --- Cards --- */
.apple-card {
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  transition: all 0.4s var(--ease-out);
}

.apple-card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-4px);
}

.apple-card-flat {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  transition: all var(--duration) var(--ease-out);
}

.apple-card-dark {
  background: #1d1d1f;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  color: #f5f5f7;
  transition: all 0.4s var(--ease-out);
}

.apple-card-dark:hover {
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  transform: translateY(-4px);
}

/* --- Sections --- */
.section-dark {
  background: #000;
  color: #f5f5f7;
}

.section-dark .text-body {
  color: #86868b;
}

.section-dark .text-headline,
.section-dark .text-display {
  color: #f5f5f7;
}

/* Ensure buttons on dark sections stay visible */
.section-dark .btn-primary {
  color: #fff !important;
  background: var(--color-accent);
}

.section-dark .btn-primary:hover {
  color: #fff !important;
  background: var(--color-accent-hover);
}

.section-dark .btn-outline {
  color: #f5f5f7;
  border-color: rgba(255,255,255,0.3);
}

.section-dark .btn-outline:hover {
  color: #fff;
  border-color: #fff;
}

.section-light {
  background: #f5f5f7;
}

.section-white {
  background: #fff;
}

/* --- Hero Image Treatment --- */
.hero-image {
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-hero);
  position: relative;
}

.hero-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.03) 100%);
  pointer-events: none;
}

.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.2s var(--ease-out);
}

.hero-image:hover img {
  transform: scale(1.03);
}

/* --- Feature Tiles (Apple-style large cards) --- */
.feature-tile {
  position: relative;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  min-height: 480px;
}

.feature-tile-content {
  position: relative;
  z-index: 2;
  padding: var(--space-12);
}

.feature-tile img {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 55%;
  object-fit: cover;
  transition: transform 0.8s var(--ease-out);
}

.feature-tile:hover img {
  transform: scale(1.05) translateY(-4px);
}

/* Photo overlay for dark cards */
.photo-overlay {
  position: relative;
  overflow: hidden;
}

.photo-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0,0,0,0.6) 100%);
  pointer-events: none;
}

.photo-overlay-dark::after {
  background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.7) 100%);
}

/* --- Photo Treatment --- */
.photo-rounded {
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.photo-rounded img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.8s var(--ease-out);
}

.photo-rounded:hover img {
  transform: scale(1.04);
}

/* Cinematic photo - larger radius, deeper shadow */
.photo-cinematic {
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-2xl);
}

.photo-cinematic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 1s var(--ease-out);
}

.photo-cinematic:hover img {
  transform: scale(1.02);
}

/* --- Pricing Cards --- */
.pricing-card {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border-light);
  border-radius: var(--radius-2xl);
  padding: var(--space-12);
  text-align: center;
  transition: all 0.4s var(--ease-out);
  position: relative;
}

.pricing-card.featured {
  border: 2px solid var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent), var(--shadow-xl);
}

.pricing-card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-6px);
}

/* --- Forms --- */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: all var(--duration) var(--ease-out);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(60px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.animate-fade-in-up {
  animation: fadeInUp 1s var(--ease-out) both;
}

.animate-fade-in {
  animation: fadeIn 0.8s var(--ease-out) both;
}

.animate-scale-in {
  animation: scaleIn 0.6s var(--ease-spring) both;
}

.animate-slide-up {
  animation: slideUp 1s var(--ease-out) both;
}

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }

/* --- Scroll-triggered Reveal --- */
.reveal {
  opacity: 0;
  transform: translateY(50px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

.reveal-scale.visible {
  opacity: 1;
  transform: scale(1);
}

.reveal-left {
  opacity: 0;
  transform: translateX(-40px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.reveal-right {
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

.reveal-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Stagger children reveal */
.stagger-children > * {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.1s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.2s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.3s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.4s; opacity: 1; transform: translateY(0); }
.stagger-children.visible > *:nth-child(6) { transition-delay: 0.5s; opacity: 1; transform: translateY(0); }

/* --- Spinner --- */
.spinner {
  border: 2px solid var(--color-border-light);
  border-top: 2px solid var(--color-accent);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Toast Notifications --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius-lg);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9999;
  backdrop-filter: blur(20px);
  animation: toastIn 0.4s var(--ease-spring);
}

.toast-success { background: rgba(22, 163, 74, 0.92); }
.toast-error { background: rgba(220, 38, 38, 0.92); }

@keyframes toastIn {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* --- Responsive Table --- */
@media (max-width: 768px) {
  .responsive-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Card Selection --- */
.card-selected {
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.15);
}

/* --- Table --- */
table tbody tr {
  transition: background var(--duration) var(--ease-out);
}

table tbody tr:hover {
  background-color: #fafafa;
}

/* --- Divider --- */
.apple-divider {
  height: 0.5px;
  background: var(--color-border-light);
  border: none;
}

/* --- Number counter animation --- */
.number-counter {
  font-variant-numeric: tabular-nums;
}

/* --- Floating badge --- */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 1rem;
  background: rgba(0,113,227,0.08);
  color: var(--color-accent);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
}

/* --- Icon circle --- */
.icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-size: 1.125rem;
  transition: all var(--duration) var(--ease-out);
}

.icon-circle:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(0,113,227,0.2);
}

/* --- Marquee / ticker (optional) --- */
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.marquee {
  display: flex;
  animation: marquee 30s linear infinite;
}

/* --- LP-specific: Full-bleed sections --- */
.lp-section {
  position: relative;
  padding: 7rem 1.5rem;
  overflow: hidden;
}

.lp-section-lg {
  padding: 9rem 1.5rem;
}

@media (max-width: 768px) {
  .lp-section {
    padding: 4rem 1rem;
  }
  .lp-section-lg {
    padding: 5rem 1rem;
  }
}

/* --- LP: Parallax-ready backgrounds --- */
.parallax-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.parallax-bg img {
  width: 100%;
  height: 120%;
  object-fit: cover;
  object-position: center;
}

/* --- LP: Stats numbers --- */
.stat-number {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 6vw, 4rem);
  letter-spacing: -0.05em;
  line-height: 1;
}

/* --- Login page special --- */
.login-container {
  display: flex;
  min-height: 100vh;
}

.login-visual {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: none;
}

@media (min-width: 768px) {
  .login-visual {
    display: block;
  }
}

.login-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-visual::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,113,227,0.15) 0%, rgba(88,86,214,0.1) 100%);
}

.login-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  max-width: 560px;
  margin: 0 auto;
}

/* --- Smooth scroll snap (optional for LP sections) --- */
@media (min-width: 1024px) {
  .scroll-snap-container {
    scroll-snap-type: y proximity;
  }
  
  .scroll-snap-section {
    scroll-snap-align: start;
  }
}

/* --- Utility: text balance --- */
.text-balance {
  text-wrap: balance;
}
