/* Common styles for ema-app-basic-en */

/* --- Layout / background --- */
.mesh-gradient {
  background:
    radial-gradient(circle at 10% 10%, rgba(11, 107, 84, 0.12), transparent 40%),
    radial-gradient(circle at 90% 15%, rgba(11, 107, 84, 0.08), transparent 35%),
    radial-gradient(circle at 20% 80%, rgba(0, 0, 0, 0.04), transparent 35%),
    #f5f9f8;
}
.glass-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(11, 107, 84, 0.2);
}
.crystal-glow {
  box-shadow: 0 0 40px 6px rgba(11, 107, 84, 0.1);
}

/* Miko badge: left-tilted (counter-clockwise) */
.ema-miko-badge {
  transform: rotate(-15deg);
  transform-origin: left top;
}

body {
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* --- Safe area (notch devices) --- */
.app-header {
  padding-top: env(safe-area-inset-top, 0);
}
.app-footer {
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.app-main {
  padding-bottom: calc(5rem + env(safe-area-inset-bottom, 0));
}

/* --- Touch targets (min 44px) --- */
.nav-link {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
}
.btn-touch {
  min-height: 44px;
  padding: 0.5rem 1rem;
}

/* --- Focus visible --- */
.focus-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0B6B54;
}

/* --- Material Symbols FILL --- */
.material-symbols-filled {
  font-variation-settings: 'FILL' 1;
}

/* --- Loading / empty states --- */
.ema-list-loading,
.ema-list-empty {
  padding: 1.5rem;
  text-align: center;
  color: #64748b;
  font-size: 0.875rem;
}

/* --- Header: two rows (title row + nav row) --- */
.app-header .header-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  min-height: auto;
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  gap: 0.5rem;
}
.header-back {
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 44px;
  padding: 0.5rem 0.5rem 0.5rem 0.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #0B6B54;
}
.header-back:hover { background: rgba(11, 107, 84, 0.08); }
.header-back .material-symbols-outlined { font-size: 1.25rem; }
.header-title {
  font-family: Cormorant Garamond, serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0B6B54;
  letter-spacing: 0.02em;
  margin: 0;
  flex-shrink: 0;
}
.header-external {
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  color: #64748b;
}
.header-external:hover { background: rgba(11, 107, 84, 0.08); color: #0B6B54; }
.header-external .material-symbols-outlined { font-size: 1.25rem; }
.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.25rem 0 0;
}
.header-nav::-webkit-scrollbar { display: none; }
.header-nav .nav-link {
  flex-shrink: 0;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 8px;
  color: #475569;
  white-space: nowrap;
}
.header-nav .nav-link:hover { color: #0B6B54; background: rgba(11, 107, 84, 0.06); }
.header-nav .nav-link.text-primary { color: #0B6B54; background: rgba(11, 107, 84, 0.1); }

/* --- Footer: app-footer (title + grid links + bottom) --- */
.app-footer {
  background: linear-gradient(to bottom, #f0fdf9 0%, #ecfdf5 100%);
  border-top: 2px solid rgba(11, 107, 84, 0.12);
  padding: 1.25rem 1rem 1rem;
  margin-top: 2rem;
  position: relative;
  overflow: hidden;
}
.app-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(11, 107, 84, 0.2), transparent);
}
.footer-inner {
  max-width: 36rem;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  min-width: 0;
}
.footer-content {
  margin-bottom: 1rem;
}
.footer-title {
  font-weight: 700;
  font-size: 0.875rem;
  color: #0B6B54;
  margin: 0 0 0.625rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  position: relative;
  padding-bottom: 0.375rem;
}
.footer-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 1.875rem;
  height: 2px;
  background: linear-gradient(to right, #0B6B54, transparent);
  border-radius: 1px;
}
.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.footer-links li { margin: 0; padding: 0; }
.footer-links a {
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
  color: #334155;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(11, 107, 84, 0.12);
  min-height: 44px;
  text-align: center;
}
.footer-links a:active {
  transform: scale(0.98);
  background: rgba(11, 107, 84, 0.1);
}
.footer-links a:hover {
  color: #0B6B54;
  background: rgba(11, 107, 84, 0.08);
  border-color: rgba(11, 107, 84, 0.25);
  box-shadow: 0 2px 6px rgba(11, 107, 84, 0.12);
}
.footer-bottom {
  border-top: 1px solid rgba(11, 107, 84, 0.15);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  color: #64748b;
}
.footer-bottom [data-consent-status] {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
  padding: 0.25rem 0;
  text-decoration: underline;
}
.footer-copy {
  flex-shrink: 0;
}
.footer-note {
  font-size: 0.6875rem;
  color: #94a3b8;
  margin-top: 0.25rem;
  display: block;
}

@media (max-width: 480px) {
  .header-inner { padding-left: 0.5rem; padding-right: 0.5rem; }
  .header-back span:not(.material-symbols-outlined) { display: none; }
  .header-back { min-width: 44px; padding: 0.5rem; }
  .header-title { font-size: 1.125rem; }
  .header-nav .nav-link {
    min-height: 40px;
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
  }
  main {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  h1 {
    font-size: 1.75rem;
  }
  .footer-inner { padding: 0.75rem 1rem; }
  .footer-title { font-size: 0.8rem; margin-bottom: 0.5rem; }
  .footer-title::after { width: 1.25rem; height: 1.5px; }
  .footer-links { grid-template-columns: repeat(2, 1fr); gap: 0.375rem; }
  .footer-links a { font-size: 0.8rem; padding: 0.5rem 0.375rem; min-height: 42px; }
  .footer-bottom [data-consent-status] { min-height: 44px; display: inline-flex; align-items: center; }
}

/* --- Consent modal --- */
.consent-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.consent-modal.is-open {
  opacity: 1;
  visibility: visible;
}
.consent-modal-content {
  background: #fff;
  border-radius: 12px;
  max-width: 480px;
  width: 100%;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}
.consent-modal.is-open .consent-modal-content { transform: scale(1); }
.consent-modal-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid #e2e8f0;
}
.consent-modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.consent-modal-title .material-symbols-outlined { font-size: 1.2rem; }
.consent-modal-body { padding: 16px 20px; }
.consent-modal-text {
  color: #334155;
  line-height: 1.6;
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.consent-modal-notice {
  margin-top: 16px;
  padding: 12px 16px;
  background: #f0fdf4;
  border-left: 4px solid #0B6B54;
  border-radius: 6px;
}
.consent-modal-notice-text {
  color: #334155;
  line-height: 1.6;
  margin: 0;
  font-size: 0.85rem;
}
.consent-modal-text-caution {
  color: #b91c1c;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}
.consent-modal-text-link { margin-top: 0.75rem; font-size: 0.85rem; }
.consent-modal-privacy-link {
  color: #0B6B54;
  font-weight: 600;
  text-decoration: underline;
}
.consent-modal-privacy-link:hover { opacity: 0.85; }
.consent-modal-footer {
  padding: 12px 20px 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.consent-modal-button {
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-size: 0.9rem;
}
.consent-modal-button-primary {
  background: #0B6B54;
  color: #fff;
}
.consent-modal-button-primary:hover { background: #084236; }
.consent-modal-button-secondary {
  background: #f1f5f9;
  color: #334155;
}
.consent-modal-button-secondary:hover { background: #e2e8f0; }
.consent-modal.hidden { display: none; }
[data-consent-status]:disabled { cursor: default; opacity: 0.9; }

@media (max-width: 480px) {
  .consent-modal-content { max-width: 100%; max-height: 80vh; }
  .consent-modal-header { padding: 12px 16px 10px; }
  .consent-modal-body { padding: 12px 16px; }
  .consent-modal-footer { padding: 10px 16px 12px; flex-direction: column; }
  .consent-modal-title { font-size: 1.1rem; }
  .consent-modal-text { font-size: 0.85rem; }
  .consent-modal-button { width: 100%; padding: 10px 16px; }
}

/* ========== Viewport / zoom (match Japanese) ========== */
.ema-section { margin-bottom: 24px; }
.ema-viewport {
  width: 100%;
  height: 500px;
  overflow: hidden;
  position: relative;
  background: #f5f9f8;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 2px solid rgba(11, 107, 84, 0.2);
  border-radius: 8px;
  touch-action: pinch-zoom;
  cursor: grab;
  user-select: none;
}
/* List background pattern options (Western-friendly) */
.ema-viewport.ema-bg-pattern {
  background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
  background-size: 200% 200%;
}
.ema-viewport.ema-bg-washi {
  background: linear-gradient(180deg, #fdfcfa 0%, #f5f3ef 40%, #ebe8e2 100%);
  background-size: 100% 100%;
}
.ema-viewport.ema-bg-dots {
  background-color: #fafbfc;
  background-image: radial-gradient(rgba(100, 116, 139, 0.14) 1px, transparent 1px);
  background-size: 22px 22px;
}
.ema-viewport.ema-bg-solid {
  background: #f1f5f9;
  background-size: 100% 100%;
}
.ema-viewport.ema-bg-mint {
  background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 40%, #bbf7d0 100%);
  background-size: 100% 100%;
}
.ema-viewport > * { position: relative; z-index: 1; }
.ema-viewport:active { cursor: grabbing; }

@media (max-width: 768px) {
  #zoomControl { display: none !important; }
}
.ema-zoom-control {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 40;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(229, 231, 235, 1);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}
.ema-canvas {
  width: fit-content;
  height: fit-content;
  position: relative;
  transform-origin: 0 0;
  z-index: 1;
}
.ema-grid-horizontal {
  position: relative;
  width: fit-content;
  padding: 24px;
  margin: 0 auto;
}
@media (max-width: 768px) {
  .ema-viewport { height: 52vh; min-height: 340px; }
  #emaGrid { padding: 16px; }
}
