/* ============================================================
   FreeCanva · Demo educativa · Hoja principal
   ============================================================ */

:root {
  /* Marca */
  --brand: #8B3DFF;
  --brand-deep: #6F2BD6;
  --brand-soft: #F1E9FE;
  --brand-glow: rgba(139, 61, 255, 0.18);

  /* Acentos */
  --teal: #2BD9C2;
  --gold: #FFC547;
  --coral: #FF6B5C;
  --pink: #FF7AB6;
  --sky: #5EB1FF;
  --lime: #A6E22E;

  /* Neutros */
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --surface-2: #F4F1EB;
  --line: #E7E2D9;
  --line-strong: #D1C9BB;
  --ink: #18181B;
  --ink-2: #3F3F46;
  --ink-mute: #71717A;
  --ink-soft: #A1A1AA;

  /* Tipografía */
  --ff-ui: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --ff-display: 'Fraunces', Georgia, serif;
  --ff-mono: 'JetBrains Mono', monospace;

  /* Sombras */
  --shadow-1: 0 1px 2px rgba(24,24,27,0.04), 0 2px 8px rgba(24,24,27,0.06);
  --shadow-2: 0 2px 6px rgba(24,24,27,0.06), 0 8px 24px rgba(24,24,27,0.10);
  --shadow-3: 0 8px 20px rgba(24,24,27,0.10), 0 24px 48px rgba(24,24,27,0.14);
  --shadow-brand: 0 4px 14px rgba(139,61,255,0.30);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--ff-ui);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 14px;
}

body {
  background:
    radial-gradient(800px 500px at 90% -10%, rgba(139,61,255,0.06), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(255,197,71,0.08), transparent 60%),
    var(--bg);
  min-height: 100vh;
  overflow: hidden;
}

button { font-family: var(--ff-ui); }
input, textarea { font-family: var(--ff-ui); }

/* ============================================================
   BOTONES BASE
   ============================================================ */
.primary-btn {
  background: var(--brand);
  color: #FFF;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 180ms ease;
  box-shadow: var(--shadow-brand);
}
.primary-btn:hover {
  background: var(--brand-deep);
  transform: translateY(-1px);
}

.ghost-btn {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 160ms ease;
}
.ghost-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.ghost-btn.small { padding: 5px 10px; font-size: 12px; }

.icon-btn {
  background: transparent;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease;
}
.icon-btn:hover { background: var(--surface-2); }

/* ============================================================
   HOME VIEW
   ============================================================ */
.home-view {
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.home-view[hidden] { display: none; }

.home-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.home-top-left { display: flex; align-items: center; gap: 22px; }

.canva-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ff-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.canva-logo.small { font-size: 0; }

.env-pill {
  font-family: var(--ff-ui);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.home-nav {
  display: flex;
  gap: 4px;
}
.home-nav a {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 160ms ease, color 160ms ease;
}
.home-nav a:hover { background: var(--surface-2); }
.home-nav a.active { color: var(--brand); background: var(--brand-soft); }

.home-top-right { display: flex; align-items: center; gap: 10px; }

.avatar-chip {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* HOME MAIN */
.home-main {
  padding: 40px 48px 80px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* Hero */
.hero {
  text-align: center;
  padding: 30px 0 50px;
}
.hero-title {
  font-family: var(--ff-display);
  font-size: 68px;
  line-height: 1;
  margin: 0 0 16px;
  font-weight: 400;
  letter-spacing: -0.025em;
}
.hero-title em {
  font-style: italic;
  color: var(--brand);
  position: relative;
}
.hero-title em::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 8px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--coral) 100%);
  border-radius: 999px;
  opacity: 0.3;
}
.hero-sub {
  font-size: 16px;
  color: var(--ink-mute);
  max-width: 540px;
  margin: 0 auto 28px;
  line-height: 1.5;
}

.hero-search {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 540px;
  margin: 0 auto;
  transition: border-color 200ms ease, box-shadow 200ms ease;
  box-shadow: var(--shadow-1);
}
.hero-search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-glow);
}
.hero-search input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: var(--ink);
}
.hero-search svg { color: var(--ink-mute); }
.kbd-hint {
  font-family: var(--ff-mono);
  font-size: 11px;
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--ink-mute);
  border: 1px solid var(--line);
}

/* Sections */
.home-section { margin-bottom: 44px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}
.section-head h2 {
  font-family: var(--ff-display);
  font-size: 26px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.section-head .meta {
  font-size: 12.5px;
  color: var(--ink-mute);
  font-family: var(--ff-mono);
}
.see-all {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.see-all:hover { text-decoration: underline; }
.home-workspace-tools { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.home-folder-label { max-width:220px; overflow:hidden; color:var(--ink-mute); font:500 11px/1.2 var(--ff-mono); text-overflow:ellipsis; white-space:nowrap; }
.home-projects-empty { grid-column:1/-1; min-height:130px; border:1px dashed var(--line-strong); border-radius:10px; }

/* Tipos de diseño */
.design-types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.type-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 200ms cubic-bezier(.2,.7,.2,1);
}
.type-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow-2);
}
.type-thumb {
  aspect-ratio: 4/3;
  border-radius: 8px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.type-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.06) 0 6px, transparent 6px 12px);
}
.type-thumb-label {
  position: relative;
  z-index: 1;
  font-family: var(--ff-display);
  font-size: 13px;
  color: #FFF;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.custom-type-card .type-thumb {
  background: var(--ink);
  border: 1px dashed rgba(255,255,255,.65);
}
.custom-type-icon {
  position: relative;
  z-index: 2;
  color: #fff;
  font: 300 38px/1 var(--ff-ui);
}
.custom-type-ruler {
  position: absolute;
  z-index: 1;
  display: block;
  background: var(--teal);
  opacity: .9;
}
.ruler-horizontal { width: 56%; height: 2px; bottom: 13px; left: 22%; }
.ruler-vertical { width: 2px; height: 56%; top: 22%; left: 22%; }
.custom-type-card:hover .custom-type-ruler { background: var(--gold); }
.type-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.type-dim {
  font-family: var(--ff-mono);
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.type-detail { font-family: var(--ff-ui); font-size: 10px; }
.custom-size-card { width: 520px; }
.custom-size-form { padding: 22px; text-align: left; }
.custom-size-form p { margin: 0 0 18px; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.custom-size-fields { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; }
.custom-size-fields label { display: grid; gap: 6px; color: var(--ink-2); font-size: 11px; font-weight: 700; }
.custom-size-fields input { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); font: 600 14px var(--ff-mono); }
.custom-size-fields input:focus { outline: 2px solid var(--brand-glow); border-color: var(--brand); }
.custom-size-times { padding-bottom: 10px; color: var(--ink-mute); font: 700 15px var(--ff-mono); }
.custom-size-hint { display: block; margin-top: 8px; color: var(--ink-mute); font-size: 11px; }
.custom-size-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
@media (max-width: 540px) {
  .custom-size-fields { grid-template-columns: 1fr; }
  .custom-size-times { display: none; }
}

/* Plantillas grid */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.template-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 220ms cubic-bezier(.2,.7,.2,1);
}
.template-card:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
  box-shadow: var(--shadow-2);
}
.template-thumb {
  aspect-ratio: 4/5;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.template-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, rgba(0,0,0,0.03) 0 6px, transparent 6px 14px);
}
.template-thumb-mini {
  position: relative;
  width: 70%;
  aspect-ratio: 1/1;
  background: #FFF;
  border-radius: 4px;
  box-shadow: var(--shadow-2);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: var(--ff-display);
}
.template-thumb-mini .t-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
}
.template-thumb-mini .t-sub {
  font-size: 9px;
  color: var(--ink-mute);
}
.template-thumb-mini .t-bar {
  height: 6px;
  background: var(--brand);
  border-radius: 999px;
  margin-top: auto;
}
.template-meta {
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
}
.template-name {
  font-size: 13px;
  font-weight: 600;
}
.template-badge {
  font-family: var(--ff-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 600;
}
.section-note {
  margin: 5px 0 0;
  color: var(--ink-mute);
  font-size: 12px;
}
.free-template-mark {
  flex: none;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-mute);
  font: 700 9px var(--ff-mono);
  letter-spacing: .08em;
}
.free-templates-section { padding-top: 4px; }
.online-template-card .template-thumb { aspect-ratio: 4/5; }
.template-thumb-online {
  background-position: center;
  background-size: cover;
}
.template-thumb-online::after { background: linear-gradient(135deg, rgba(255,255,255,.08), transparent 55%); }
.online-template-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(10,16,24,.08) 20%, rgba(10,16,24,.72) 100%);
}
.online-template-copy {
  position: absolute;
  z-index: 2;
  inset: auto 14px 14px;
  display: grid;
  gap: 8px;
  text-shadow: 0 2px 14px rgba(0,0,0,.35);
}
.online-template-title {
  max-width: 90%;
  white-space: pre-line;
  font: 800 24px/1.02 var(--ff-display);
  letter-spacing: -.02em;
}
.online-template-source {
  width: fit-content;
  padding: 4px 7px;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 999px;
  background: rgba(15,23,42,.38);
  font: 600 9px var(--ff-mono);
  letter-spacing: .02em;
}

/* Recientes */
.recents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.recent-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: all 180ms ease;
}
.recent-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.recent-thumb {
  aspect-ratio: 16/10;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}
.recent-card-actions {
  position: absolute;
  z-index: 5;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 5px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
}
.recent-card:hover .recent-card-actions,
.recent-card:focus-within .recent-card-actions {
  opacity: 1;
  transform: translateY(0);
}
.recent-card-action {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 7px;
  background: rgba(24,24,27,.82);
  color: #fff;
  box-shadow: 0 4px 12px rgba(24,24,27,.2);
  cursor: pointer;
  font: 700 16px/1 var(--ff-ui);
}
.recent-card-action:hover { background: var(--brand); }
.recent-card-action.danger:hover { background: var(--coral); }
.recent-thumb .canvas-document {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.32);
  transform-origin: center;
  pointer-events: none;
  width: 800px;
  height: 800px;
  background: white;
}
.recent-preview-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  overflow: hidden;
  transform: translate(-50%, -50%) scale(var(--recent-preview-scale, .18));
  transform-origin: center;
  box-shadow: 0 5px 16px rgba(24,24,27,.14);
  pointer-events: none;
}
.recent-preview-canvas .ed-element {
  transition: none;
}
.recent-preview-canvas .ed-el-text {
  overflow: hidden;
}
.recent-info {
  padding: 8px 10px;
}
.recent-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.recent-date {
  font-size: 11px;
  color: var(--ink-mute);
  font-family: var(--ff-mono);
  margin-top: 2px;
}
.home-project-location {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -2px 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--brand-glow);
  border-radius: 9px;
  background: linear-gradient(90deg, var(--brand-soft), rgba(255,255,255,.82));
  color: var(--ink-2);
}
.home-project-location-icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  box-shadow: var(--shadow-1);
  font-size: 17px;
}
.home-project-location small,
.home-project-location code { display: block; }
.home-project-location small {
  margin-bottom: 3px;
  color: var(--ink-mute);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.home-project-location code {
  max-width: min(56vw, 620px);
  overflow: hidden;
  color: var(--ink);
  font: 600 12px/1.3 var(--ff-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.home-project-location-note {
  margin-left: auto;
  color: var(--ink-mute);
  font-size: 11px;
  text-align: right;
}
@media (max-width: 680px) {
  .home-project-location { align-items: flex-start; }
  .home-project-location-note { display: none; }
  .home-project-location code { max-width: calc(100vw - 130px); }
}

/* Footer */
.home-foot {
  border-top: 1px solid var(--line);
  padding: 20px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--ink-mute);
  background: var(--surface);
}
.foot-meta { font-family: var(--ff-mono); font-size: 11px; }
