/* StudyCenter.ph base styles — SPEC section 10 */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  font-weight: 400;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 var(--space-3);
  letter-spacing: -0.015em;
}

h1 { font-size: clamp(1.9rem, 1.4rem + 2.2vw, 2.9rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 1.2rem + 1vw, 1.9rem); }
h3 { font-size: 1.2rem; font-weight: 600; }

p { margin: 0 0 var(--space-4); max-width: var(--measure); }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--space-2);
  background: var(--ink);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  z-index: 100;
}
.skip-link:focus { left: var(--space-4); }

/* --- Layout ---------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: var(--space-4);
}

main { flex: 1 0 auto; padding-block: var(--space-6) var(--space-8); }

.narrow { max-width: 30rem; margin-inline: auto; }

/* Ruled-notebook lines behind page headers (SPEC 10.4) */
.page-header {
  position: relative;
  padding-block: var(--space-5);
  margin-bottom: var(--space-5);
}
.page-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 27px,
    var(--line) 27px 28px
  );
  opacity: 0.55;
  z-index: -1;
  mask-image: linear-gradient(to bottom, #000 40%, transparent 100%);
}
.page-header > * { position: relative; }
.page-header p { color: var(--ink-soft); margin-bottom: 0; }

/* --- Header and footer ----------------------------------------------- */

.site-header {
  background: var(--paper-raised);
  border-bottom: var(--border);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 64px;
  flex-wrap: wrap;
}

.logo {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.logo span { color: var(--notebook-blue); }

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.site-nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.site-nav a:hover { color: var(--link); text-decoration: underline; }

.site-footer {
  background: var(--paper-raised);
  border-top: var(--border);
  padding-block: var(--space-6);
  color: var(--ink-soft);
  font-size: 0.95rem;
}
.site-footer nav {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

/* --- Buttons ---------------------------------------------------------- */

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

/* The buy button: highlighter yellow, navy text, navy border, sticker
   shadow. The most visible element on the page (SPEC 10.4). */
.btn-buy,
.btn-primary {
  background: var(--highlighter);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: var(--sticker-shadow);
}
.btn-buy:hover,
.btn-primary:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
.btn-buy:active,
.btn-primary:active { transform: translate(3px, 3px); box-shadow: none; }

.btn-secondary {
  background: var(--paper-raised);
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { border-color: var(--link); color: var(--link); }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--link);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.btn-block { display: block; width: 100%; }

/* --- Forms ------------------------------------------------------------ */

.field { margin-bottom: var(--space-5); }
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-2);
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  padding: var(--space-3);
  background: var(--paper-raised);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--notebook-blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.18);
}
.field .help { color: var(--ink-faint); font-size: 0.9rem; margin-top: var(--space-2); }
.field .error { color: var(--danger); font-size: 0.9rem; margin-top: var(--space-2); }
.field-invalid input,
.field-invalid select,
.field-invalid textarea { border-color: var(--danger); }

fieldset { border: none; margin: 0; padding: 0; }

.card {
  background: var(--paper-raised);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.card + .card { margin-top: var(--space-5); }

/* --- Messages --------------------------------------------------------- */

.messages { list-style: none; margin: 0 0 var(--space-5); padding: 0; }
.messages li {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: var(--border);
  background: var(--paper-raised);
  margin-bottom: var(--space-2);
}
.messages .success { background: var(--mint-bg); border-color: var(--mint); }
.messages .error { background: var(--danger-bg); border-color: var(--danger); }

.form-errors {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  color: var(--danger);
}
.form-errors p:last-child { margin-bottom: 0; }

/* --- Bits ------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--mint-bg);
  color: #0C6B52;
}
.badge-super { background: var(--highlighter); color: var(--ink); }

.muted { color: var(--ink-soft); }
.stack > * + * { margin-top: var(--space-4); }
.meta { color: var(--ink-faint); font-size: 0.95rem; }

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--paper-raised);
  box-shadow: 0 0 0 1px var(--line);
}
.avatar-placeholder {
  display: grid;
  place-items: center;
  background: var(--link);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
}

/* --- Home hero (placeholder until Phase 2) ---------------------------- */

.hero { padding-block: var(--space-7); }
.hero h1 { max-width: 16ch; }
.hero p { font-size: 1.15rem; color: var(--ink-soft); }
.hero-actions { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-top: var(--space-5); }

@media (max-width: 40rem) {
  .site-header .wrap { min-height: 56px; }
  .card { padding: var(--space-5) var(--space-4); }
  .hero { padding-block: var(--space-5); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .btn-buy:hover,
  .btn-primary:hover,
  .btn-buy:active,
  .btn-primary:active { transform: none; }
}

/* A checkbox reads better with the box beside its label, not under it. */
.field-check .checkbox { font-weight: 500; align-items: flex-start; }
.field-check .checkbox input { margin-top: 0.2rem; flex: 0 0 auto; }
.field-check .help { margin-left: 1.7rem; }

/* Error pages */
.error-page .card p:last-child { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: 0; }

/* Selling Q&A (/sell/help/) */
.help-page { max-width: 44rem; margin-inline: auto; }
.help-contents {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-5);
}
.help-section h2 { margin-top: 0; }
.help-section h3 {
  font-size: 1.05rem;
  margin: var(--space-5) 0 var(--space-2);
}
.help-section h2 + h3 { margin-top: var(--space-3); }
.help-section p, .help-section ul { margin-top: 0; }
.help-section ul { padding-left: 1.25rem; }
.help-section li + li { margin-top: var(--space-2); }
.help-section { scroll-margin-top: var(--space-4); }
.help-cta { text-align: center; margin-top: var(--space-6); }
