/* ============================================
   Ringtone Maker v3 - Styles
   ============================================ */

/* === Fonts === */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/montserrat-400.ttf') format('truetype');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/montserrat-500.ttf') format('truetype');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/montserrat-600.ttf') format('truetype');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/montserrat-700.ttf') format('truetype');
}

/* === Variables === */
:root {
  --bg: #ffffff;
  --text: #4B5A6D;
  --muted: #617381;
  --primary: #4B5A6D;
  --accent: #91D8D9;
  --accent-weak: #e8f7f7;
  --area-bg: #F5F2EE;
  --border: #b8d4d5;
  --dashed: rgba(145, 216, 217, 0.6);
  /* Legacy aliases */
  --brand: #4B5A6D;
  --blue: #4B5A6D;
  --blue-weak: #DFF3F3;
}

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

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: min(1120px, 92vw);
  margin: 0 auto;
}

.page-root {
}

/* === Header === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.site-header .container {
  width: min(1320px, 92vw);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

/* Topbar for editor/download pages */
.topbar {
  background: var(--bg);
  padding: 48px 0 30px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(940px, 92vw);
  margin: 0 auto;
  position: relative;
}

.topbar-logo {
  display: flex;
  align-items: center;
}

.topbar-logo img {
  height: 128px;
  width: auto;
}

.topbar .btn-back {
  position: absolute;
  left: 0;
  top: 0;
}

.btn-back {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue-weak);
  border: 1px solid var(--border);
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: all 0.15s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.btn-back:hover {
  background-color: #e8e8e8;
}

.btn-back svg {
  width: 20px;
  height: 20px;
}

.brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #111827;
  text-decoration: none;
}

.btn {
  appearance: none;
  border: 0;
  outline: 0;
  cursor: pointer;
  font-weight: 500;
  border-radius: 45px;
  padding: 8px 20px;
  font-size: 16px;
}

.btn-upload {
  background: #000;
  color: #fff;
}

.btn-upload:hover {
  filter: brightness(1.1);
}

.btn-upload:active {
  transform: translateY(1px);
}

.btn-upload:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* === Hero === */
.hero {
  padding: 48px 0 0;
  text-align: center;
}

.hero__logo {
  display: inline-block;
  margin-bottom: 40px;
}

.hero__logo img {
  height: 128px;
  width: auto;
}

.hero__subtitle {
  margin: 30px 0;
  color: #000000;
  opacity: 0.7;
  line-height: 1.58;
  font-size: 18px;
  font-weight: 400;
  font-family: "Montserrat", system-ui, -apple-system, sans-serif;
}

/* === Dropzone === */
.dropwrap {
  display: flex;
  justify-content: center;
  margin-bottom: 45px;
}

.dropzone {
  width: min(940px, 96vw);
  background: var(--area-bg);
  border-radius: 20px;
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.dropzone__inner {
  margin: 20px;
  padding: 70px 30px;
  position: relative;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  overflow: hidden;
}

.dropzone__inner::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' viewBox='0 0 100 100'%3E%3Crect x='0.3' y='0.3' rx='3' ry='3' width='99' height='99' fill='none' stroke='rgb(75,90,109)' stroke-opacity='0.4' stroke-width='2' stroke-linecap='round' stroke-dasharray='3 8' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") center/100% 100% no-repeat;
}

.dropzone__icon {
  margin-bottom: 30px;
}

.dropzone__title {
  font-size: 18px;
  font-weight: 700;
  color: #000000;
}

.dropzone__subtitle {
  margin-top: 20px;
  color: #000000;
  font-size: 14px;
  opacity: 0.5;
  font-weight: 400;
  font-family: "Montserrat", system-ui, -apple-system, sans-serif;
}

.dropzone:hover,
.dropzone:focus-visible {
  box-shadow: 0 6px 24px rgba(75, 90, 109, 0.18);
  transform: translateY(-1px);
}

.dropzone.is-dragover .dropzone__inner {
  background: rgba(145, 216, 217, 0.15);
}

/* === Steps === */
.howto {
  padding: 0 0 64px;
  text-align: center;
}

.howto__title {
  margin: 0 30px 45px;
  font-size: 24px;
  font-weight: 600;
}

.howto .steps {
  width: min(940px, 92vw);
  margin: 0 auto;
}

.steps {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, 1fr);
}

.steps .step:nth-child(-n+2) {
  grid-column: span 3;
}

.steps .step:nth-child(n+3) {
  grid-column: span 2;
}

.step {
  text-align: left;
  border-radius: 20px;
  padding: 32px 24px;
  background: var(--blue-weak);
}

.step__title {
  margin: 0 0 8px;
  line-height: 1.58;
  font-size: 16px;
  font-weight: 700;
  color: #000000;
}

.step__desc {
  margin: 0;
  color: #374151;
  font-size: 14px;
  line-height: 1.5;
}

@media screen and (max-width: 530px) {
  .howto .steps {
    display: flex;
    flex-direction: column;
  }
}

/* === Instructions (download page) === */
.instructions .steps {
  grid-template-columns: repeat(3, 1fr);
}

.instructions .steps .step:nth-child(-n+2),
.instructions .steps .step:nth-child(n+3) {
  grid-column: span 1;
}

.instructions-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.instructions-tab {
  padding: 10px 24px;
  border: none;
  border-radius: 20px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.instructions-tab:hover {
  background: #e8e8e8;
}

.instructions-tab.active {
  background: var(--primary);
  color: #fff;
}

.instructions-tab.active:hover {
  background: #3d4a5a;
}

.instructions-content {
  display: none;
}

.instructions-content.active {
  display: block;
}

@media screen and (max-width: 530px) {
  .instructions .steps {
    display: flex;
    flex-direction: column;
  }
}

/* === Footer === */
.site-footer {
  margin-bottom: 60px;
}

.site-footer .container {
  width: min(1320px, 96vw);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-inner--centered {
  justify-content: center;
}

.footer-inner small {
  color: #000000;
  font-size: 12px;
  font-weight: 400;
}

.privacy-link {
  color: #000000;
  text-decoration: underline;
}

.privacy-link:hover {
  color: #374151;
}

.up-link {
  color: #000000;
  font-size: 12px;
  font-weight: 400;
  text-decoration: none;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

.up-link:hover {
  color: #374151;
  text-decoration: underline;
}

/* === Audio Container === */
.audio-container {
  width: min(940px, 92vw);
  background: var(--area-bg);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 30px auto;
  padding: 0 20px 40px;
}


@media (max-width: 600px) {
  .audio-container {
    margin: 30px auto;
    padding: 0 15px 30px;
  }
}

/* === Ringtone Maker === */
.ringtone-maker {
  min-width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: Arial, sans-serif;
  position: relative;
}

.waveform-wrapper {
  position: relative;
  margin-top: 45px;
}

.waveform-container {
  border-radius: 2px;
  background: #ffffff;
  width: 100%;
  min-height: 100px;
  box-sizing: border-box;
}

.waveform-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 16px;
  border-radius: 20px;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.3s;
  white-space: nowrap;
}

.waveform-hint.is-hidden {
  opacity: 0;
}

.region-progress {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(75, 90, 109, 0.3);
  pointer-events: none;
  z-index: 1;
}

.controls {
  margin-top: 30px;
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.controls-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.play-pause-buttons {
  display: flex;
  gap: 8px;
}

.play-pause-buttons--mobile {
  display: none;
  gap: 8px;
}

.btn-circle {
  background: white;
  border: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.btn-circle .icon-play {
  margin-top: 3px;
  margin-left: 2px;
}

.btn-circle .icon-pause {
  margin-top: 4px;
}

#play-btn svg {
  margin-top: 3px;
  margin-left: 2px;
}

#pause-btn svg {
  margin-top: 4px;
}

.btn-circle:hover {
  background: #e8e8e8;
}

.btn-circle:disabled {
  cursor: default;
  opacity: 0.6;
}

.btn-circle:disabled:hover {
  background: white;
}

.btn-circle[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
}

.btn-circle[aria-pressed="true"]:hover {
  background: #3d4a5a;
}

.volume-and-repeat {
  display: flex;
  align-items: center;
  gap: 12px;
}

.volume-control {
  max-width: 130px;
  background: white;
  border-radius: 24px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: none;
  height: 40px;
}

.sound-icon-wrapper {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
}

.volume-range {
  width: 80px;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.2);
  outline: none;
  padding: 0;
}

.volume-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #000000;
  cursor: pointer;
  border: none;
}

.volume-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #000000;
  cursor: pointer;
  border: none;
}

.btn-pill {
  background: white;
  border: none;
  cursor: pointer;
  height: 40px;
  padding: 0 12px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: none;
  font-weight: 500;
  font-size: 16px;
}

.btn-pill:hover {
  background: #e8e8e8;
}

.btn-pill[aria-pressed="true"] {
  background: var(--blue);
}

.btn-pill[aria-pressed="true"]:hover {
  background: #3d4a5a;
}

.btn-pill[aria-pressed="true"] .repeat-text {
  color: #ffffff;
}

.btn-pill[aria-pressed="true"] .repeat-svg {
  color: #ffffff;
}

.repeat-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.repeat-text {
  line-height: 1;
  color: #000000;
}

.time-controls {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 24px;
  height: 40px;
  padding: 0 16px;
  gap: 12px;
}

.time-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-value {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.time-duration {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
}

.time-duration .duration-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.time-duration .duration-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.time-duration.is-warning .duration-value {
  color: #FF9500;
}

.time-duration.is-error .duration-value {
  color: #FF3B30;
}

.time-input-wrapper {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 36px;
}

.time-number {
  width: 100%;
  height: 100%;
  padding: 0 20px 0 2px;
  border: none;
  border-radius: 8px;
  text-align: left;
  font-size: 16px;
  font-weight: 500;
  background-color: white;
  color: #1a1a1a;
  -moz-appearance: textfield;
}

.time-number::-webkit-outer-spin-button,
.time-number::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.time-number:focus {
  outline: none;
}

.time-arrows {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0;
}

.time-group .arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s;
}

.time-group .arrow:hover {
  color: var(--text);
}

.time-group .arrow svg {
  width: 10px;
  height: 6px;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn-primary {
  background: #000;
  color: white;
  border: none;
  border-radius: 53px;
  padding: 10px 20px;
  font-weight: 500;
  font-size: 16px;
  cursor: pointer;
  box-shadow: none;
}

.btn-primary:hover {
  background: #333;
}

.btn-primary:disabled {
  background: #b8d4d5;
  cursor: default;
}

.repeat-mobile {
  display: none;
}

/* === Read-only mode === */
.ringtone-maker.read-only {
  display: flex;
  flex-direction: row;
  align-items: center;
  min-width: 100%;
  position: relative;
  margin-top: 40px;
}

.ringtone-maker.read-only .waveform-container {
  padding: 8px;
  border-radius: 20px;
  min-height: 60px;
}

.ringtone-maker.read-only .btn-circle {
  width: 60px;
  height: 60px;
  margin-right: 10px;
}

.ringtone-maker.read-only .controls {
  display: none;
}

/* === Read-only controls === */
.download-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-top: 30px;
}

.format-switcher {
  display: flex;
  align-items: center;
  background: white;
  border-radius: 53px;
  overflow: hidden;
}

.format-switcher__button {
  border: none;
  border-radius: 49px;
  padding: 10px 24px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.2s ease;
  background: #fff;
  color: #000;
}

.format-switcher__button:hover {
  background: #e8e8e8;
}

.format-switcher__button.selected {
  background: var(--primary);
  color: #fff;
}

.format-switcher__button.selected:hover {
  background: #3d4a5a;
}

.btn-download {
  background: #000;
  color: white;
  border: none;
  border-radius: 53px;
  padding: 10px 20px;
  font-weight: 500;
  font-size: 16px;
  cursor: pointer;
  box-shadow: none;
}

.btn-download:hover {
  background: #333;
}

.btn-download:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.mobile-player-topbar {
  display: none;
  margin-bottom: 10px;
}

/* === WaveSurfer Region === */
#waveform ::part(region) {
  border-top: 2px solid #425341 !important;
  border-bottom: 2px solid #425341 !important;
}

/* === WaveSurfer Region Handles === */
#waveform ::part(region-handle-left),
#waveform ::part(region-handle-right) {
  width: 5px !important;
  background-color: #425341 !important;
  border-left-color: #425341 !important;
  border-right-color: #425341 !important;
  border-radius: 0 !important;
}

/* === Error pages === */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
}

.error-code {
  font-size: 120px;
  font-weight: 700;
  color: var(--blue);
  margin: 0;
  line-height: 1;
}

.error-message {
  font-size: 24px;
  margin: 20px 0 40px;
  color: var(--muted);
}

/* === Mobile Responsive === */
@media (max-width: 910px) {
  .hero {
    padding-top: 24px;
  }

  .topbar {
    padding: 24px 0;
  }

  .btn-pill {
    padding: 0 14px;
    font-size: 14px;
    border-radius: 20px;
  }


  .mobile-player-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .format-switcher__button {
    padding: 10px 12px;
    font-size: 15px;
  }
}

@media (max-width: 730px) {
  .time-controls {
    display: none;
  }
}

@media (max-width: 768px) {
  .container,
  .topbar-inner,
  .audio-container,
  .howto .steps,
  .instructions .container,
  .site-footer .container,
  .edit-ringtone-page .container,
  .make-ringtone-page .container {
    width: min(940px, 96vw);
  }

  .dropzone {
    width: min(940px, 98vw);
  }
}

@media (max-width: 530px) {
  .container,
  .topbar-inner,
  .audio-container,
  .howto .steps,
  .instructions .container,
  .site-footer .container,
  .edit-ringtone-page .container,
  .make-ringtone-page .container,
  .dropzone {
    width: 100%;
  }

  .dropzone,
  .dropzone__inner,
  .audio-container,
  .step,
  .waveform-container,
  .ringtone-maker.read-only .waveform-container {
    border-radius: 0;
  }

  .dropzone__inner::before {
    border-radius: 0;
  }

  .audio-container {
    padding-left: 15px;
    padding-right: 15px;
  }

  .controls {
    justify-content: space-between;
  }

  .controls-left {
    display: contents;
  }

  .controls-right {
    flex: 0 0 100%;
    display: flex;
    justify-content: center;
    margin-top: 20px;
  }
}

@media (max-width: 600px) {
  .dropzone__inner::before {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none' viewBox='0 0 100 100'%3E%3Crect x='0.5' y='0.5' rx='5' ry='5' width='99' height='99' fill='none' stroke='rgb(75,90,109)' stroke-opacity='0.4' stroke-width='2' stroke-linecap='round' stroke-dasharray='3 8' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") center/100% 100% no-repeat;
  }
}

@media (pointer: coarse) {
  .region-handle {
    width: 20px;
  }

  .region-handle--left {
    left: -10px;
  }

  .region-handle--right {
    right: -10px;
  }
}

/* === Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
}

.modal-overlay.is-open {
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: #fff;
  border-radius: 8px;
  max-width: 700px;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  position: relative;
  padding: 30px;
}

.modal-body .policy-page {
  padding: 0;
}

.modal-body .page-root {
  min-height: auto;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #666;
  line-height: 1;
  padding: 4px 8px;
}

.modal-close:hover {
  color: #000;
}

.modal-body h1 {
  margin: 0 0 24px;
  font-size: 24px;
}

.modal-body h2 {
  margin: 24px 0 12px;
  font-size: 18px;
}

.modal-body p {
  margin: 0 0 12px;
  line-height: 1.6;
}

.modal-body ul {
  margin: 0 0 12px 24px;
  line-height: 1.6;
}
