/* ===================================================================
   Hash Generator — earth87human (cream surface, tomato accent)
   Textarea input + light hash output tiles (Tomato Hero).
   =================================================================== */

/* ============ Design tokens ============ */
:root {
  --bg: #faf6f1;
  --bg-2: #f3eee5;
  --surface: #ffffff;
  --surface-2: #faf6ed;
  --surface-3: #eee7d8;
  --border: #e8dfcc;
  --border-soft: #f0e9da;
  --text: #1f1a14;
  --text-2: #5c5547;
  --text-3: #6e6557;
  --text-faint: #b5ac9b;
  --accent: #e85f4d;
  --accent-2: #d44a39;
  --accent-soft: rgba(232, 95, 77, 0.10);
  --accent-glow: rgba(232, 95, 77, 0.30);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.12);

  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
             "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK",
             sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============ Reset ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 235, 220, 0.55) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1;
  line-height: 1.55;
  touch-action: manipulation;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ============ App layout ============ */
.app {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px) clamp(12px, 3vw, 24px) 80px;
}

/* ============ Top bar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 28px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-2);
}
.brand:hover { color: var(--accent); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
@media (max-width: 380px) {
  .nav-link { font-size: 12px; padding: 4px 8px; }
}
.nav-link:hover { color: var(--accent); background: var(--surface-2); }

.lang-switcher {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  transition: border-color var(--transition);
}
.lang-switcher:hover { border-color: var(--text-3); }
.lang-switcher:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }

/* ============ Page title ============ */
.page-title {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 6px;
}
.page-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 36px;
}

/* ============ Workspace ============ */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 64px;
}

/* ============ Textarea ============ */
.textarea-section {
  width: 100%;
}

.text-input {
  width: 100%;
  min-height: 120px;
  padding: clamp(16px, 3vw, 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}
.text-input::placeholder {
  color: var(--text-faint);
}
.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============ Output card (light Tomato Hero) ============ */
.device {
  margin: 0 auto;
  max-width: 620px;
  width: 100%;
}

.device-bezel {
  position: relative;
  border-radius: var(--r-xl);
  padding: clamp(16px, 3vw, 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

/* Output panel → light recessed cream */
.device-screen {
  position: relative;
  border-radius: var(--r-lg);
  padding: clamp(16px, 4vw, 28px) clamp(14px, 3vw, 24px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

.screen-glare { display: none; }

/* ============ Hash grid ============ */
.hash-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hash-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition);
}
.hash-tile:hover {
  border-color: var(--accent);
}

.hash-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.hash-value {
  font-family: var(--font-mono);
  font-size: clamp(11px, 2.2vw, 13px);
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
  line-height: 1.3;
  min-height: 1.3em;
  transition: opacity var(--transition);
}

.hash-value:empty,
.hash-value[data-empty="true"] {
  opacity: 0.4;
}

/* ============ Hash copy buttons ============ */
.hash-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-end;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.hash-copy-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.hash-copy-btn:active {
  background: var(--surface-2);
}
.hash-copy-btn.is-copied {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.hash-copy-btn:not([data-has-value]) {
  opacity: 0.3;
  pointer-events: none;
}

/* ============ Device brand (removed in light theme) ============ */
.device-brand { display: none; }

/* ============ Info / SEO section ============ */
.info {
  max-width: 720px;
  margin: 40px auto 0;
  padding: 0 4px;
  color: var(--text-2);
  line-height: 1.7;
}
.info h2 {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 26px 0 10px;
}
.info h2:first-child { margin-top: 0; }
.info p { margin-bottom: 10px; font-size: 15px; }

/* ============ Footer ============ */
.site-footer {
  max-width: 720px;
  margin: 56px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 6px;
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 8px;
}

/* ============ Responsive ============ */
@media (max-width: 600px) {
  .app { padding: 8px 12px 60px; }
  .topbar { padding: 4px 0 20px; }
  .lang-switcher { padding: 4px 22px 4px 8px; font-size: 12px; max-width: 140px; }
  .page-title { margin-bottom: 4px; }
  .page-sub { margin-bottom: 24px; }
  .text-input { min-height: 100px; font-size: 15px; }
  .device-bezel { padding: 16px 14px; border-radius: var(--r-lg); }
  .device-screen { border-radius: var(--r-md); padding: 14px 10px; }
  .hash-grid { gap: 8px; }
  .hash-tile { padding: 10px 12px; }
  .hash-value { font-size: 11px; }
  .info { padding: 16px 4px; }
  .info h2 { font-size: 20px; margin-top: 28px; }
}

@media (max-width: 420px) {
  .topbar-right .nav-link { display: none; }
  .topbar-right { gap: 6px; }
  .lang-switcher { max-width: 130px; }
  .hash-grid { grid-template-columns: 1fr; }
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ Focus visible ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible) { outline: none; }

/* High contrast support */
@media (prefers-contrast: more) {
  :root { --border: #555; --border-soft: #444; --text-3: #ccc; }
}
