/* ============================================================
   TUTTOS — Base Styles & CSS Custom Properties
   All themes override these variables.
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* --- Spacing --- */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  40px;

  /* --- Border radius --- */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 40px;
  --radius-pill: 999px;

  /* --- Typography --- */
  --font-body:    'Trebuchet MS', 'Arial Rounded MT Bold', Arial, sans-serif;
  --font-display: 'Arial', 'Trebuchet MS', Arial, sans-serif;
  --font-mono:    'Courier New', Courier, monospace;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-md: 16px;
  --font-size-lg: 20px;
  --font-size-xl: 28px;
  --font-size-2xl: 40px;

  /* --- Transitions --- */
  --transition-fast: 0.12s ease;
  --transition-med:  0.25s ease;

  /* --- Shadows --- */
  --shadow-sm:  2px 3px 0px var(--color-shadow);
  --shadow-md:  4px 6px 0px var(--color-shadow);
  --shadow-lg:  6px 9px 0px var(--color-shadow);
  --shadow-inset: inset 2px 3px 0px var(--color-shadow);
}

html {
  font-size: var(--font-size-md);
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.6;
  background-image: var(--bg-pattern);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.tuttos-wrap {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header  header"
    "sidebar main"
    "footer  footer";
  min-height: 100vh;
}

@media (max-width: 768px) {
  .tuttos-wrap {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main"
      "sidebar"
      "footer";
  }
}

.tuttos-header  { grid-area: header; }
.tuttos-sidebar { grid-area: sidebar; }
.tuttos-main    { grid-area: main; padding: var(--space-lg); }
.tuttos-footer  { grid-area: footer; }

/* ============================================================
   PANELS (the main UI card/box)
   ============================================================ */

.panel {
  background: var(--color-panel);
  border: 3px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.panel--sm { padding: var(--space-md); }
.panel--flush { padding: 0; }

.panel__title {
  font-family: var(--font-display);
  font-size: var(--font-size-lg);
  color: var(--color-accent-1);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-border);
}

/* ============================================================
   BUTTONS — Flat, large, chunky
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  font-weight: bold;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: 3px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-md);
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: var(--shadow-sm);
}

.btn--primary {
  background: var(--color-btn-primary);
  color: var(--color-btn-primary-text);
  border-color: var(--color-btn-primary-border);
}
.btn--primary:hover {
  background: var(--color-btn-primary-hover);
}

.btn--secondary {
  background: var(--color-btn-secondary);
  color: var(--color-btn-secondary-text);
  border-color: var(--color-btn-secondary-border);
}
.btn--secondary:hover {
  background: var(--color-btn-secondary-hover);
}

.btn--danger {
  background: #e05555;
  color: #fff;
  border-color: #b03030;
}
.btn--danger:hover { background: #c03030; }

.btn--ghost {
  background: transparent;
  color: var(--color-accent-1);
  border-color: var(--color-accent-1);
  box-shadow: none;
}
.btn--ghost:hover {
  background: var(--color-accent-1);
  color: var(--color-panel);
}

.btn--sm {
  font-size: var(--font-size-sm);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
}

.btn--lg {
  font-size: var(--font-size-lg);
  padding: 16px 36px;
  border-radius: var(--radius-lg);
}

.btn--wide { width: 100%; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: var(--font-size-md);
  background: var(--color-input-bg);
  color: var(--color-text);
  border: 3px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-accent-1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.form-error {
  font-size: var(--font-size-sm);
  color: #e05555;
  margin-top: var(--space-xs);
}

/* ============================================================
   ALERTS & NOTICES
   ============================================================ */

.alert {
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  margin-bottom: var(--space-md);
  font-size: var(--font-size-sm);
}

.alert--success {
  background: #d4f5d4;
  border-color: #5cb85c;
  color: #2d6a2d;
}

.alert--error {
  background: #fde8e8;
  border-color: #e05555;
  color: #7a1a1a;
}

.alert--info {
  background: var(--color-accent-2-light);
  border-color: var(--color-accent-2);
  color: var(--color-text);
}

/* ============================================================
   TUCKS DISPLAY
   ============================================================ */

.tucks-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--color-tucks-bg);
  color: var(--color-tucks-text);
  border: 2px solid var(--color-tucks-border);
  border-radius: var(--radius-pill);
  padding: 4px 14px;
  font-family: var(--font-display);
  font-size: var(--font-size-sm);
  font-weight: bold;
}

/* ============================================================
   AVATAR DISPLAY
   ============================================================ */

.avatar-display {
  position: relative;
  width: 100px;
  height: 100px;
}

.avatar-display img {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  background: var(--color-panel);
  border: 3px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xl);
  max-width: 480px;
  width: 90%;
  position: relative;
  animation: modal-pop 0.2s ease;
}

@keyframes modal-pop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.modal__close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
}

.modal__title {
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  color: var(--color-accent-1);
  margin-bottom: var(--space-md);
}

/* ============================================================
   ITEM DROP ANIMATION
   ============================================================ */

.drop-popup {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--color-panel);
  border: 3px solid var(--color-accent-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  z-index: 900;
  animation: drop-slide-in 0.3s ease, drop-slide-out 0.3s ease 3.7s forwards;
  max-width: 300px;
}

@keyframes drop-slide-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes drop-slide-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

.drop-popup img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.drop-popup__text strong {
  display: block;
  font-family: var(--font-display);
  color: var(--color-accent-1);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--color-text-muted); }
.text-accent  { color: var(--color-accent-1); }
.text-sm      { font-size: var(--font-size-sm); }
.text-lg      { font-size: var(--font-size-lg); }
.text-display { font-family: var(--font-display); }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap-sm { gap: var(--space-sm); }
.flex-gap-md { gap: var(--space-md); }
.flex-wrap   { flex-wrap: wrap; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); }

@media (max-width: 600px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.hidden { display: none !important; }
